You are here

public function Instagram::user_recent in Drupagram 7

Same name and namespace in other branches
  1. 6 drupagram.lib.php \Instagram::user_recent()

Get the most recent media published by a user. GET /users/{user-id}/media/recent

PARAMETERS access_token A valid access token. max_id Return media earlier than this max_id min_id Return media later than this min_id count Count of media to return min_timestamp Return media after this UNIX timestamp max_timestamp Return media before this UNIX timestamp

@example: https://api.instagram.com/v1/users/3/media/recent/?access_token=10920197...

File

./drupagram.lib.php, line 285
Classes to implement the full Instagram API

Class

Instagram
Primary Instagram API implementation class Supports the full REST API for drupagram.

Code

public function user_recent($id = NULL, $params = array(), $use_auth = TRUE) {
  if (empty($id)) {
    $params['!user_id'] = 'self';
  }
  elseif (is_numeric($id)) {
    $params['!user_id'] = $id;
  }
  elseif ($accounts = $this
    ->user_lookup($id)) {
    $params['!user_id'] = $accounts[0]->id;
  }
  $params['count'] = 10;

  // @TODO: Implement a way to remember each user's last image id so we can
  // just fetch the images older than that one, hopefully saving requests.
  return $this
    ->fetch('user_recent', $params, $use_auth);
}