2017 © Pedro Peláez
 

library instaphp

Composer compliant version of Instaphp by sesser (Randy)

image

fishmarket/instaphp

Composer compliant version of Instaphp by sesser (Randy)

  • Wednesday, December 5, 2012
  • by fishmarket
  • Repository
  • 0 Watchers
  • 0 Stars
  • 287 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

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

Getting Started

Add to composer.json and install/update:, (*2)

{
    "require": {
        "fishmarket/instaphp": "*"
    }
}

index.php:, (*3)

```php 'YOUR_CLIENT_ID' ); // Get an instance of the Instaphp object $api = Instaphp::Instance(null, $config); // Get the response for Popular media $response = $api->Media->Popular(); ``` Alternatively, you could provide an access token: ```php $api = Instaphp::Instance('YOUR_ACCESS_TOKEN'); ``` You can override the default configurations like above. Here are the defaults for quick reference: ```php public $configDefaults = array( 'version'=> 'v1', 'endpoint'=> 'https://api.instagram.com', 'endpoint_timeout'=> '10', 'client_id'=> null, 'client_secret'=> null, 'oauth_path'=> '/oauth/authorize/?client_id={client_id}&response_type=code&redirect_uri={redirect_uri}', 'oauth_token_path'=> 'oauth/access_token', 'redirect_uri'=> '', ); ``` 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][0] [API][1]. 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 Media->Popular(); //-- Check if an error was returned from the API if (empty($response->error)) foreach ($response->data as $item) printf('%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(); , (*4)

//-- 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);
    }
}

The Versions

05/12 2012

dev-master

9999999-dev https://github.com/fishmarket/Instaphp

Composer compliant version of Instaphp by sesser (Randy)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by James DeBlasse

api instagram

05/12 2012

1.0.0

1.0.0.0 https://github.com/fishmarket/Instaphp

Composer compliant version of Instaphp by sesser (Randy)

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

by James DeBlasse

api instagram