Download the PHP package php-instagram-api/php-instagram-api without Composer

On this page you can find all versions of the php package php-instagram-api/php-instagram-api. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package php-instagram-api

PHP Instagram API

This is a PHP 5.3+ API wrapper for the Instagram API

The API comes with a cURL client (Instagram\Net\CurlClient) to access the Instagran API. You can create your own client, it just has to implement Instagram\Net\ClientInterface.


The API

All methods that access the API can throw exceptions. If the API request fails for any reason other than an expired/missing access token an exception of type \Instagram\Core\ApiException will be thrown. If the API request fails because of an expired/missing access token an exception of type \Instagram\Core\ApiAuthException will be thrown. You can use this to redirect to your authorization page.

Authentication

$auth_config = array(
    'client_id'         => '',
    'client_secret'     => '',
    'redirect_uri'      => '',
    'scope'             => array( 'likes', 'comments', 'relationships' )
);

$auth = new Instagram\Auth( $auth_config );

$auth->authorize();

$_SESSION['instagram_access_token'] = $auth->getAccessToken( $_GET['code'] );

$instagram = new Instagram\Instagram;
$instagram->setAccessToken( $_SESSION['instagram_access_token'] );
$current_user = $instagram->getCurrentUser();

Basic Usage

$instagram = new Instagram\Instagram( $_SESSION['instagram_access_token'] );
$user = $instagram->getUser( $user_id );
$media = $instagram->getMedia( $media_id );
$tag = $instagram->getTag( 'mariokart' );
$location = $instagram->getLocation( 3001881 );
$current_user = $instagram->getCurrentUser();

Current User

The current user object will give you the currently logged in user

$current_user = $instagram->getCurrentUser();

With this object you can:

$current_user->follow( $user );
$current_user->unfollow( $user );
$current_user->block( $user );
$current_user->unblock( $user );

$feed = $current_user->getFeed();
$liked_media = $current_user->getLikedMedia();

$current_user->ignoreFollowRequest( $user );
$current_user->approveFollowRequest( $user );

You can also perform all the functions you could on a normal user

Getting Media

Users, tags, locations, and the current user have media associated with them.

This will return recent media from the 4 objects:

$user->getMedia();
$tag->getMedia();
$location->getMedia();
$current_user->getMedia();

You can pass an array of parameters to getMedia(). These parameters will be passed directly to the API. Check the API for a list of available parameters.

$user->getMedia(
    array( 'count' => 3 )
);
$tag->getMedia(
    array( 'max_tag_id' => $max_tag_id )
);
$location->getMedia(
    array( 'max_id' => $max_id )
);

Images and Videos

You can distinguish between images and videos with Media::getType(). This will return video or image. Video files can be accessed with Media::getStandardResVideo() and Media::getLowResVideo(). The image methods on a video will return a still of the video.

Collections

When making a call to a method that returns more than one of something (e.g. getMedia(), searchUsers() ), a collection object will be returned. Collections can be iterated, counted, and accessed like arrays.

$user = $instagram->getUser( $user_id );
$media = $user->getMedia();
foreach( $media as $photo ) {
     ...
}
$media_count = count( $media );
$first_photo = $media[0];

The collection object will sometimes have an identifier to the "next page" that can be used to obtain the next page of the collection.

To obtain the identifier for the next page you call getNext() on the collection object.

For example:

$user = $instagram->getUser( $user_id );
$media = $user->getMedia();
$next_page = $media->getNext();

Example usage:

<a href="user_media.php?max_id=">

In user_media.php you would check for a next page when obtaining the user media.

$user = $instagram->getUser( $user_id );
$params = isset( $_GET['max_id'] ) ? array( 'max_id' => $_GET['max_id'] ) : null;
$media = $user->getMedia( $params );

Unfortunately API methods require different params to be passed to them in order to obtain the next set of results (e.g. Tags require the max_tag_id param ).

Searching

You can search for locations, media, tags, and users.

$locations = $instagram->searchLocations( $lat, $lng );
$media = $instagram->searchMedia( $lat, $lng );
$tags = $instagram->searchTags( 'tag' );
$users = $instagram->searchUsers( 'username' );

All versions of php-instagram-api with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package php-instagram-api/php-instagram-api contains the following files

Loading the files please wait ....