You are here

function instagram_feeds_urls_from_feed in Instagram Feeds 7

Creates an array of feeds urls from Instagram Feed.

Parameters

string $nid: Node nid.

2 calls to instagram_feeds_urls_from_feed()
instagram_feeds_get_tasks in ./instagram_feeds.module
Creates tasks for instagram_feeds_cron() and for batch operations.
instagram_feeds_import_tab_form_submit in includes/instagram_feeds.pages.inc
Submit handler for instagram_feeds_import_tab_form().

File

./instagram_feeds.module, line 1172

Code

function instagram_feeds_urls_from_feed($nid) {
  $urls =& drupal_static(__FUNCTION__);
  if (!isset($urls)) {
    $urls = array();
  }
  if (!isset($urls[$nid])) {
    $config = instagram_feeds_block_get_config($nid);
    $must_have = instagram_feeds_get_all_conditions();
    if (count($config['tags'])) {
      $client_id = variable_get('instagram_feeds_client_id', '');
      $terms = taxonomy_term_load_multiple($config['tags']);
      foreach ($terms as $term) {
        $url = INSTAGRAM_FEEDS_BASE_URL . '/tags/' . $term->name . '/media/recent?client_id=' . $client_id;
        if (isset($must_have[$url])) {
          $urls[$nid][] = $url;
        }
      }
    }
    if (count($config['users'])) {
      $access_token = variable_get('instagram_feeds_access_token', '');
      $terms = taxonomy_term_load_multiple($config['users']);
      foreach ($terms as $term) {
        $url = INSTAGRAM_FEEDS_BASE_URL . '/users/' . $term->field_instf_uid[LANGUAGE_NONE][0]['value'] . '/media/recent?access_token=' . $access_token;
        if (isset($must_have[$url])) {
          $urls[$nid][] = $url;
        }
      }
    }
  }
  return $urls[$nid];
}