/** * Get a single instagram. * * @param string $shortcode * The instagram shortcode. */ protected function fetchInstagram($shortcode) { $instagram =& drupal_static(__FUNCTION__); if (!isset($instagram)) { // Check for dependencies. // @todo There is perhaps a better way to do that. if (!class_exists('\\Instagram\\Instagram')) { drupal_set_message(t('Instagram library is not available. Consult the README.md for installation instructions.'), 'error'); return; } if (!isset($this->configuration['client_id'])) { drupal_set_message(t('The client ID is not available. Consult the README.md for installation instructions.'), 'error'); return; } if (empty($this->configuration['client_id'])) { drupal_set_message(t('The client ID is missing. Please add it in your Instagram settings.'), 'error'); return; } $instagram_object = new \Instagram\Instagram(); $instagram_object->setClientID($this->configuration['client_id']); $result = $instagram_object->getMediaByShortcode($shortcode)->getData(); if ($result) { return $result; } else { throw new MediaTypeException(NULL, 'The media could not be retrieved.'); } } }