protected function SocialContentInstagram::getRowsHashtag in Social Content 7.2
Get rows from a list of hashtags.
Parameters
array $settings: The settings to use to get the Instagram content.
array $global_settings: The global settings for Instagram.
mixed $last_id: The id of the last imported Instagram posts.
Return value
mixed Array of Instagram posts or FALSE on error.
1 call to SocialContentInstagram::getRowsHashtag()
- SocialContentInstagram::getRows in modules/
instagram/ social_content_instagram.class.inc - Get the rows to import.
File
- modules/
instagram/ social_content_instagram.class.inc, line 320 - Social Content Instagram class.
Class
- SocialContentInstagram
- @file Social Content Instagram class.
Code
protected function getRowsHashtag($settings, $global_settings, $last_id = NULL) {
if (!empty($settings['hashtag'])) {
$params = array(
'access_token' => $global_settings['access_token'],
);
if ($last_id) {
$params['min_tag_id'] = $last_id;
}
if (!empty($settings['limit'])) {
$params['count'] = $settings['limit'];
}
$posts = array();
$hashtags = explode(' ', $settings['hashtag']);
// Explode hashtags by space and request images for each hashtag.
foreach ($hashtags as $hashtag) {
$url = $global_settings['api_url'] . '/' . $global_settings['api_version'] . '/tags/' . trim($hashtag, '#') . '/media/recent/?' . drupal_http_build_query($params);
$result = $this
->httpRequest($url);
if ($result->code == 200) {
$result_data = json_decode($result->data);
foreach ($result_data->data as &$row) {
$row->hashtag = $hashtag;
}
$posts = array_merge($posts, $result_data->data);
}
else {
watchdog('social_content_instagram', 'Error fetching feed, data: %data', array(
'%data' => $result->data,
), WATCHDOG_WARNING);
return FALSE;
}
}
return $posts;
}
return FALSE;
}