Skip to content

Commit

Permalink
Added support for subscriptions to the real-time API
Browse files Browse the repository at this point in the history
- Source cosenary#35
- Prestar atenção ao comentário sobre o método DELETE caso não funcione.
  • Loading branch information
GuidoBR committed Aug 12, 2015
1 parent 2ffb768 commit ab3712a
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions src/Instagram.php
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,63 @@ public function searchLocation($lat, $lng, $distance = 1000)
return $this->_makeCall('locations/search', false, array('lat' => $lat, 'lng' => $lng, 'distance' => $distance));
}

/**
* List all your subscriptions
*
* @return mixed
*/
public function listSubscriptions()
{
return $this->_makeCall('subscriptions', false, ['client_secret' => $this->getApiSecret()]);
}

/**
* Create a subscription
*
* @param string $object Object type (user, tag, geography, location)
* @param string [optional] $object_id Name of the object you want to subscribe : can be a location, a tag
* @param array [optional] $additionalParams Distance in meter (max. distance: 5km = 5000)
* @param string [optional] $aspect Aspect of the object, only media is supported for this time.
* @return mixed
*/
public function createSubscription($object, $object_id = '', $additionalParams = [], $aspect = 'media')
{
$params = [
'object' => $object,
'aspect' => $aspect,
'verify_token' => $this->getVerifyToken(),
'client_secret' => $this->getApiSecret(),
'callback_url' => $this->getApiCallback(),
];

return $this->_makeCall('subscriptions', false, array_merge($params, $additionalParams), 'POST');
}

/**
* Delete a subscription
*
* @param string $id Id of the subscription you want to delete
* @return mixed
*/
public function deleteSubscriptionById($id)
{
$params = ['id'=>$id, 'verify_token'=>$this->getVerifyToken(), 'client_secret' =>$this->getApiSecret()];
return $this->_makeCall('subscriptions', false, $params, 'DELETE');
}

/**
* Delete subscriptions
*
* @param string $object Object type that you want to delete (Ex.: trag, user, geography, location)
* @return mixed
*/
public function deleteSubscriptions($object)
{
$params = ['object'=>$object, 'verify_token'=>$this->getVerifyToken(), 'client_secret' =>$this->getApiSecret()];
return $this->_makeCall('subscriptions', false, $params, 'DELETE');
}


/**
* Pagination feature.
*
Expand Down

0 comments on commit ab3712a

Please sign in to comment.