protected function Instagram::fetch in Drupagram 6
Same name and namespace in other branches
- 7 drupagram.lib.php \Instagram::fetch()
Get an array of Instagram objects from an API endpoint
6 calls to Instagram::fetch()
- Instagram::self_feed in ./
drupagram.lib.php - See the authenticated user's feed. GET /users/self/feed
- Instagram::self_liked in ./
drupagram.lib.php - See the authenticated user's list of media they've liked. Note that this list is ordered by the order in which the user liked the media. Private media is returned as long as the authenticated user has permission to view that media. Liked…
- Instagram::tag_recent in ./
drupagram.lib.php - Get the most recent hash media published. GET v1/tags/!tag_name/media/recent
- Instagram::user_lookup in ./
drupagram.lib.php - Instagram::user_recent in ./
drupagram.lib.php - Get the most recent media published by a user. GET /users/{user-id}/media/recent
File
- ./
drupagram.lib.php, line 175 - Classes to implement the full Instagram API
Class
- Primary Instagram API implementation class Supports the full REST API for drupagram.
Code
protected function fetch($key, $params = array(), $use_auth = TRUE) {
$results = array();
if (array_key_exists($key, $this->endpoints)) {
$path = $this->endpoints[$key];
}
else {
watchdog('drupagram', 'Endpoint key not found: !key', array(
'!key' => $key,
), WATCHDOG_ERROR);
return FALSE;
}
$response = $this
->call($path, $params, 'GET', $use_auth);
switch ($key) {
case 'user':
case 'user_search':
case 'user_follows':
case 'user_followed_by':
$class = 'InstagramUser';
break;
default:
$class = 'InstagramMedia';
break;
}
if (isset($response) && is_array($response)) {
$response = array_filter($response);
}
if (!empty($response)) {
foreach ($response as $key => $item) {
if ($key != 'data') {
continue;
}
elseif (!empty($item) && isset($item[0])) {
foreach ($item as $object) {
$results[] = new $class($object);
}
}
else {
$results[] = new $class($item);
}
}
}
return $results;
}