PHP class that provide basic using and dealing with Instagram APT (without authentication)
Current directory structre of Instagram-Basic-API is contains to directory:
- /src: contains Instagram class
- /examples contains examples of how to use Instagram class
To use Instagram class for get popular photos/videos on instagram, you need to create php file or modify existing one to add popular photos/vidoes.
For instance, I create /popular_posts.php, and require Instagram class and call get_popular_posts on it:
// require Instagram class
require_once 'src/Instagram.php';
// define Instagram class instance with passing client id
$instagram = new Instagram('Your Client ID');
// output last popular posts as readable array
print_r($instagram->get_popular_posts());
You can also access to local objects in popular posts like 'link', 'username', 'images':
// require Instagram class
require_once 'src/Instagram.php';
// define Instagram class instance with passing client id
$instagram = new Instagram('Your Client ID');
// store data of first post in variable
$first_post = $instagram->get_popular_posts()[0];
// output link, username, and thumbnail image of first post
echo 'Link => ' . $first_post->link . '<br>';
echo 'From => @ ' . $first_post->user->username . '<br>';
echo 'Thumbnail: <br>';
echo '<img src="' . $first_post->images->thumbnail->url ." width="' . $first_post->images->thumbnail->width . '" height="' . $first_post->images->thumbnail->height . '" alt="" />';
these are current methods available for several purposes:
to make class instance and passing your app client id for getting different data from class public methods.
$instagram = new Instagram('Your_Client_ID');
return last popular posts (photos and videos)
$instagram->get_popular_posts()
return the result of your Instagram user searching
$instagram->search_user($user)
return user id of Instagram username
$instagram->get_user_id_from_username($username)
return user media (last posts of selected user)
$instagram->get_user_media($username)
return last posts (this will include only images, text, username, and id of last posts)
Notice: You need to call 'get_user_media' firstly.
$instagram->get_last_posts()
return last comments of posts of user
Notice: You need to call 'get_user_media' firstly.
$instagram->get_last_comments()
return last comments of selected post
Notice: You need to call 'get_user_media' firstly.
$instagram->get_last_comments_from_post($post_id)
Just create new app/client on Instagram developer web app and it will provide client_id after client creation immediately:
Instagram Developer Documentation
Look to examples available on this repository and test them on your local server.