Skip to content

PHP class that provide basic using and dealing with Instagram APT (without authentication)

Notifications You must be signed in to change notification settings

devAhmed07/Instagram-Basic-API

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Instagram-Basic-API

PHP class that provide basic using and dealing with Instagram APT (without authentication)

How to use it

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="" />';

Available methods

these are current methods available for several purposes:

Instagram('Your_Client_ID')

to make class instance and passing your app client id for getting different data from class public methods.

$instagram = new Instagram('Your_Client_ID');

get_popular_posts()

return last popular posts (photos and videos)

$instagram->get_popular_posts()

search_user($user)

return the result of your Instagram user searching

$instagram->search_user($user)

get_user_id_from_username($username)

return user id of Instagram username

$instagram->get_user_id_from_username($username)

get_user_media($username)

return user media (last posts of selected user)

$instagram->get_user_media($username)

get_last_posts()

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()

get_last_comments()

return last comments of posts of user

Notice: You need to call 'get_user_media' firstly.

$instagram->get_last_comments()

get_last_comments_from_post($post_id)

return last comments of selected post

Notice: You need to call 'get_user_media' firstly.

$instagram->get_last_comments_from_post($post_id)

How to create client_id?

Just create new app/client on Instagram developer web app and it will provide client_id after client creation immediately:

Instagram Developer Documentation

Recommentations

Look to examples available on this repository and test them on your local server.

About

PHP class that provide basic using and dealing with Instagram APT (without authentication)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • PHP 100.0%