-
Notifications
You must be signed in to change notification settings - Fork 31
Custom Params
Justin Stolpe edited this page May 21, 2022
·
8 revisions
The Instagram Graph API PHP SDK allows for fully customizable request. By default, the SDK tries to return all possible fields and parameters. If, for whatever reason, you want to make your own request or specify certain parameters, this page is for you.
By default the getSelf() will ask for and return all possible parameters and fields for an endpoint. However, you can pass an array into any getSelf() function call to specify only certain parameters. The key value pair in the custom params passed in must match the required key values expected by the Instagram Graph API. Let's look at business discovery as an example.
/**
* sdk defaults to return all fields
* 'business_discovery.username(<USERNAME>){username,website,name,ig_id,id,profile_picture_url,biography,follows_count,followers_count,media_count,media{id,username,caption,like_count,comments_count,timestamp,media_product_type,media_type,owner,permalink,media_url,children{id,media_type,media_url}}}'
*/
$userBusinessDiscovery = $businessDiscovery->getSelf();
/**
* specifying our params we just want the username and profile picture
* 'business_discovery.username(<USERNAME>){username,profile_picture_url}'
*/
$params = array( // key value pairs must match what the Instagram Graph API expects for the endpoint you are hitting
// fields is the GET url parameter and the value is the string the Instagram Graph API requires for business discovery endpoint
'fields' => 'business_discovery.username(<USERNAME>){username,profile_picture_url}'
);
$userBusinessDiscovery = $businessDiscovery->getSelf( $params );