1. Go to this page and download the library: Download flarone/instagram-graph-api library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
flarone / instagram-graph-api example snippets
use Instagram\User\BusinessDiscovery;
$config = array( // instantiation config params
'user_id' => '<IG_USER_ID>',
'username' => '<USERNAME>', // string of the Instagram account username to get data on
'access_token' => '<ACCESS_TOKEN>',
);
// instantiate business discovery for a user
$businessDiscovery = new BusinessDiscovery( $config );
// initial business discovery
$userBusinessDiscovery = $businessDiscovery->getSelf();
use Instagram\User\Media;
use Instagram\User\MediaPublish;
$config = array( // instantiation config params
'user_id' => '<USER_ID>',
'access_token' => '<ACCESS_TOKEN>',
);
// instantiate user media
$media = new Media( $config );
$imageContainerParams = array( // container parameters for the image post
'caption' => '<CAPTION>', // caption for the post
'image_url' => '<IMAGE_URL>', // url to the image must be on a public server
);
// create image container
$imageContainer = $media->create( $imageContainerParams );
// get id of the image container
$imageContainerId = $imageContainer['id'];
// instantiate media publish
$mediaPublish = new MediaPublish( $config );
// post our container with its contents to instagram
$publishedPost = $mediaPublish->create( $imageContainerId );
// first we have to instantiate the core Instagram class with our access token
$instagram = new Instagram\Instagram( array(
'access_token' => '<ACCESS_TOKEN>'
) );
/**
* Here we are making our request to instagram and specify the endpoint along with our custom params.
* There is a custom function for get, post, and delete.
* $instagram->get()
* $instagram->post()
* $instagram->delete()
*
* Here is the skeleton for the customized call.
*/
$response = $instagram->method( array(
'endpoint' => '/<ENDPOINT>',
'params' => array( // query params key/values must match what IG API is expecting for the endpoint
'<KEY>' => '<VALUE>',
'<KEY>' => '<VALUE>',
// ...
)
) );
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.