Constants

VERSION

VERSION

Version of the client class

API_VERSION

API_VERSION

API version. Used in URLS

HOST

HOST

Host of the instagram API

METHOD_POST

METHOD_POST

METHOD_GET

METHOD_GET

METHOD_PUT

METHOD_PUT

METHOD_UPDATE

METHOD_UPDATE

METHOD_PATCH

METHOD_PATCH

DEFAULT_LIMIT

DEFAULT_LIMIT

Properties

$version

$version : 

Type

$access_token

$access_token : 

Type

$client_id

$client_id : 

Type

$client_secret

$client_secret : 

Type

$redirect_uri

$redirect_uri : 

Type

$limit

$limit : 

Type

$options

$options : 

Options array to hold special HTTP options. These are not implemented yet, but will allow you to turn off SSL verification or change the protocol.

Type

Methods

get()

get(string  $path, array  $params = array()) : \Webmakersteve\Instagram\Response

Helper function to do a GET request. Accessible to public in case an endpoint is not implemented as a method abstraction.

Parameters

string $path

The path that will be entered into the URL filter.

array $params

The params to be entered into the URL.

Returns

\Webmakersteve\Instagram\Response

post()

post(string  $path, array  $params = array()) : \Webmakersteve\Instagram\Response

Helper function to do a POST request. Accessible to public in case an endpoint is not implemented as a method abstraction.

Parameters

string $path

The path that will be entered into the URL filter.

array $params

The params to be entered into the request body.

Returns

\Webmakersteve\Instagram\Response

put()

put(string  $path, array  $params = array()) : \Webmakersteve\Instagram\Response

Helper function to do a PUT request. Accessible to public in case an endpoint is not implemented as a method abstraction.

Parameters

string $path

The path that will be entered into the URL filter.

array $params

The params to be entered into the request body.

Returns

\Webmakersteve\Instagram\Response

__construct()

__construct(array  $options = array()) : \Webmakersteve\Instagram\Client

Constructor function. Takes client ID, secret, and redirect URI to establish the class. Can take other options

Parameters

array $options

Options to create the client with. Requires 'client_id', 'client_secret', and 'redirect_uri' to properly work.

Returns

\Webmakersteve\Instagram\Client

getLoginUrl()

getLoginUrl(string  $scopes = array('basic')) : string

Helper function to get the login URL.

Parameters

string $scopes

An array of scopes you want to request the API authorize you for.

Returns

string —

The URL to be used in a redirect request.

setAccessToken()

setAccessToken(  $access_token) : \Webmakersteve\Instagram\Client

Helper function to set the Instagram access token. Accessible publicly to allow it to be set after the OAuth flow

Parameters

$access_token

Returns

\Webmakersteve\Instagram\Client

getOAuthToken()

getOAuthToken(string  $code, boolean  $access_code_only = false) : \Webmakersteve\Instagram\Response|string

Converts an access code into an access token through the API

Parameters

string $code

Code passed through a query parameter by the API

boolean $access_code_only

Whether to return the entire object or just the access code.

Returns

\Webmakersteve\Instagram\Response|string —

Returns a Response object or a string based on the second parameter

getUser()

getUser(string|integer  $id = 'self') : \Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

Helper function to get user data from the API

Parameters

string|integer $id

'self' as an ID returns the info about the current user. Otherwise, an ID returns data about that user.

Returns

\Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

searchUser()

searchUser(string|integer  $name, integer  $limit = null) : \Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

Helper function to get search user data from the API

Parameters

string|integer $name

The name as a query to search.

integer $limit

The limit of results to return

Returns

\Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

getUserMedia()

getUserMedia(string|integer  $id = 'self', integer  $limit = null, integer  $min = false, integer  $max = false) : \Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

Helper function to get posts by a given user.

Parameters

string|integer $id

'self' as an ID returns the posts by the current user. Otherwise, an ID returns posts by that user.

integer $limit

Max number of users to return. Otherwise defaults to the default limit.

integer $min

The min ID of users to return. Useful for pagination.

integer $max

The max ID of users to return. Useful for pagination.

Returns

\Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

getUserLiked()

getUserLiked(integer  $limit = null, integer  $max = false) : \Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

Helper function to get liked users of the logged in user

Parameters

integer $limit

Max number of users to return. Otherwise defaults to the default limit.

integer $max

The max ID of users to return. Useful for pagination

Returns

\Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

getUserFeed()

getUserFeed(integer  $limit = null) : \Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

Helper function to get the currently logged in user's feed.

Parameters

integer $limit

Max number of users to return. Otherwise defaults to the default limit.

Returns

\Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

searchTags()

searchTags(string  $q) : \Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

Searches for currently used Instagram tags.

Parameters

string $q

The query to search

Returns

\Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

getTag()

getTag(string  $tag) : \Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

Gets information about a given tag.

Parameters

string $tag

The tag string. Can be returned from the searchTags method

Returns

\Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

getTaggedMedia()

getTaggedMedia(string  $tag, integer  $limit = null, integer  $min = false, integer  $max = false) : \Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

Get posts tagged with a given hashtag.

Parameters

string $tag

A hashtag. The # will be trimmed.

integer $limit

Max number of users to return. Otherwise defaults to the default limit.

integer $min

The min ID of posts to return. Useful for pagination.

integer $max

The max ID of posts to return. Useful for pagination.

Returns

\Webmakersteve\Instagram|\Webmakersteve\Instagram\Response

getUserAgent()

getUserAgent() : string

Returns a user agent for the API.

Returns

string

getDefaultOptions()

getDefaultOptions() : array

Returns default options for the guzzle HTTP client. Things like specifying that we want JSON.

Returns

array

buildInstagramURL()

buildInstagramURL(string  $path, array  $params = false, boolean  $raw = false, string  $method = self::METHOD_GET) : string

Creates the Instagram URL from the path. Adds access token automatically unless $raw is specified.

Parameters

string $path

String of the path with no prefixing characters, e.g. 'users/self'

array $params

Parameters to put into the URL. Prioritizes parameter replacement into the URL, and after that will add them as a query string.

boolean $raw

Determines whether the URL should be returned RAW. That is, without the access token and auth params.

string $method

Should be assigned to one of the method constants. Determines whether params should be placed as a query string.

Returns

string

parseResponse()

parseResponse(  $response) : \Webmakersteve\Instagram\Response

Reads response information and returns the format best suited to the body. Usually JSON

Parameters

$response

Returns

\Webmakersteve\Instagram\Response

doRequest()

doRequest(string  $path, string  $method = self::METHOD_GET, array  $params = array()) : \Webmakersteve\Instagram\Response

Does the request and returns the Guzzle response

Parameters

string $path

The path to be entered into the URL filter.

string $method

The method constant to be compared against to determine where the parameters go

array $params

The parameters to be sent with the request.

Throws

\Webmakersteve\Instagram\AuthenticationException
\Webmakersteve\Instagram\NotPermittedException
\Webmakersteve\Instagram\Exception

Returns

\Webmakersteve\Instagram\Response

getLimitSize()

getLimitSize(integer  $override) : integer

Helper function to return a limit or an override if it is not a falsy value

Parameters

integer $override

The overriding limit. If it is not null, it will return that value. Otherwise it returns the default limit.

Returns

integer

getAccessToken()

getAccessToken() : string

Helper function to get the Instagram access token. If it isn't set throws an exception.

Throws

\Webmakersteve\Instagram\AuthenticationException

Returns

string —

API access token