Skip to content
Browse files

Added getAuthorizationUrl method. Fixed bug with optionals parameters…

… on getUserFeedMethod. Added optional parameter "count" too.
  • Loading branch information...
1 parent b83e23d commit ba7714a9d1181e39f2bbc3eb0bc77b55014e7c0b Olivier Balais committed Nov 2, 2011
Showing with 14 additions and 7 deletions.
  1. +14 −7 Instagram.php
View
21 Instagram.php
@@ -35,7 +35,7 @@ class Instagram {
'authorize' => 'https://api.instagram.com/oauth/authorize/?client_id=%s&redirect_uri=%s&response_type=%s',
'access_token' => 'https://api.instagram.com/oauth/access_token',
'user' => 'https://api.instagram.com/v1/users/%d/?access_token=%s',
- 'user_feed' => 'https://api.instagram.com/v1/users/self/feed?access_token=%s&max_id=%d&min_id=%d',
+ 'user_feed' => 'https://api.instagram.com/v1/users/self/feed?%s',
'user_recent' => 'https://api.instagram.com/v1/users/%d/media/recent/?access_token=%s&max_id=%d&min_id=%d&max_timestamp=%d&min_timestamp=%d',
'user_search' => 'https://api.instagram.com/v1/users/search?q=%s&access_token=%s',
'user_follows' => 'https://api.instagram.com/v1/users/%d/follows?access_token=%s',
@@ -201,13 +201,20 @@ public function setAccessToken($accessToken) {
* @return string
*/
public function openAuthorizationUrl() {
- $authorizationUrl = sprintf($this->_endpointUrls['authorize'],
+ header('Location: ' . $this->getAuthorizationUrl());
+ exit(1);
+ }
+
+ /**
+ * Generate Instagram credentials verification page URL.
+ * Usefull for creating a link to the Instagram authentification page.
+ * @return string
+ */
+ public function getAuthorizationUrl() {
+ return sprintf($this->_endpointUrls['authorize'],
$this->_config['client_id'],
$this->_config['redirect_uri'],
self::RESPONSE_CODE_PARAM);
-
- header('Location: ' . $authorizationUrl);
- exit(1);
}
/**
@@ -225,8 +232,8 @@ public function getUser($id) {
* @param integer $maxId. Return media after this maxId.
* @param integer $minId. Return media before this minId.
*/
- public function getUserFeed($maxId = null, $minId = null) {
- $endpointUrl = sprintf($this->_endpointUrls['user_feed'], $this->getAccessToken(), $maxId, $minId);
+ public function getUserFeed($maxId = null, $minId = null, $count = null) {
+ $endpointUrl = sprintf($this->_endpointUrls['user_feed'], http_build_query(array('access_token' => $this->getAccessToken(), 'max_id' => $maxId, 'min_id' => $minId, 'count' => $count)));
$this->_initHttpClient($endpointUrl);
return $this->_getHttpClientResponse();
}

0 comments on commit ba7714a

Please sign in to comment.
Something went wrong with that request. Please try again.