Download the PHP package fishmarket/instaphp without Composer

On this page you can find all versions of the php package fishmarket/instaphp. 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 instaphp

This is a Composer compliant version of Instaphp which was coded by sesser (Randy) and can be found here.

Getting Started

Add to composer.json and install/update:

index.php:

Alternatively, you could provide an access token:

You can override the default configurations like above. Here are the defaults for quick reference:

The rest of the documentation follows the original Instaphp docs below

Instaphp v1.0 (original readme below)

This software is licensed under The MIT License. Please see the file named 'LICENSE' for futher details.

About

Instaphp is a small(ish) PHP library to access Instagram's API. It's main goal was to be easy to use, lightweight and have as few dependencies as possible. It's currently only compatible with PHP 5 >= 5.3 but there are very few 5.3 features being used and it's relatively trivial to convert it to versions < 5.3.

Instaphp is currently being used to power instaview.me.

Quickstart Guide

To get an idea of how the library works, it's best to understand the various endpoints provided by the API itself. The Instagram API currently has eight "endpoints" in which to retrieve data from their system:

In actuality, these eight endpoints can be summarized into four major endpoints:

Relationships are really an attribute of Users. Comments and Likes are both attributes of Media. Geographies are also an attribute of Media however, that particular endpoint is only available for subscriptions created for a particular location. Currently, Instaphp does not have a mechanism that supports subscriptions.

These four main "endpoints" are the basis for this library and allows a good separation for the various data you can pull from Instagram.

Example: Getting the current Popular photos

//-- Include our library
include_once 'instaphp/instaphp.php';

//-- Get an instance of the Instaphp object
$api = Instaphp\Instaphp::Instance();

//-- Get the response for Popular media
$response = $api->Media->Popular();

//-- Check if an error was returned from the API
if (empty($response->error))
    foreach ($response->data as $item)
        printf('<img src="%s" width="%d" height="%d" alt="%s">', $item->images->thumbnail->url, $item->images->thumbnail->width, $item->images->thumbnail->height, empty($item->caption->text) ? 'Untitled':$item->caption->text);

Example: Authentication

Instagram uses oAuth to authenticate its users. That means you follow a link to their site, login to their system, and grant an application access on your behalf. It's a fairly common scheme for handling authentication without passing sensitive data (e.g. your username and password) across (possibly) unsecure lines (e.g. non-https).

For Instaphp, you must have an API Key, API Secret and callback URL in order for oAuth to work. The basic flow looks like this:

  1. User clicks a link to "Login"
  2. User lands on Instagram's site and enters username/password
  3. Upon successful login, user is asked if they want to grant application access to their photos
  4. If user allows access, Instagram redirects user to callback URL of application with a code
  5. Application calls API with code to validate authentication
  6. Application is then given an access token to "sign" the calls to the API

Here's how it looks:

//-- The oAuth URL can be found in the Config object
$oAuthUrl = Instaphp\Config::Instance()->GetOAuthUri();

<!-- Here's a link -->
<a href="">Login</a>

//-- To authenticate, simply grab the code in your callback url
$code = $_GET['code'];
if (!empty($code)) {
    //-- Create an Instaphp instance
    $api = Instaphp\Instaphp::Instance();

    //-- Authenticate
    $response = $api->Users->Authenticate($code);

    //-- If no errors, grab the access_token (and cookie it, if desired)
    if (empty($response->error)) {
        $token = $response->auth->access_token;
        setcookie('instaphp', $token, strtotime('30 days'));
        //-- once you have a token, update the Instaphp instance so it passes the token for future calls
        $api = Instaphp\Instaphp::Instance($token);
    }
}

All versions of instaphp 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 fishmarket/instaphp contains the following files

Loading the files please wait ....