fantasyrock/instagram 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fantasyrock/instagram

最新稳定版本:v1.0.8

Composer 安装命令:

composer require fantasyrock/instagram

包简介

Instagram PHP API wrapper

README 文档

README

Instagram API package

Installation

The reccomended way to install this pacakge is through Composer. The package is available on Packagist

You may require the package by calling composer require fantasyrock/instagram

or add the package manually into your composer.json file:

{
    "require": {
        "fantasyrock/instagram": "*"
    }
}

Package currently works with Guzzle HTTP Client Library and needs to be added into your composer file:

{
    "require": {
        "guzzle/guzzle": "^6.0",
    }
}

Adapters

Currently the packages offers only Guzzle as HTTP adapter but you may easily build your own by extending HttpAbstract and implementing HttpAdapterInterface

Example

<?php 

require 'vendor/autoload.php';

use Instagram\Adapters\Http\GuzzleAdapter;
use Instagram\Instagram;

$adapter = new GuzzleAdapter('access_token');
$factory = new Instagram($adapter);

Sessions

As adapters the package currently only offers support for Native Sessions. However like adapters you may easily build your own by extending SessionAbstract and implementing SessionAdapterInterface

Example

<?php 

require 'vendor/autoload.php';

use Instagram\Adapters\Storage\NativeSessionAdapter;
use Instagram\Security\Credentials;

$storage     = new NativeSessionAdapter();
$credentials = new Credentials(['client_id', 'client_secret', 'redirect_uri'], $storage);

Endpoints

  • User
  • Media
  • Tag
  • Comment
  • Like
  • Relationship
  • Geography
  • Location

Credentials

API needs a valid access token provided by instagram. If your application already has access to user tokens you may pass it directly to the HttpClientAdapter in our case GuzzleAdapter.

To obtain the access key you may generate the login URL using Credentials part of the package and requesting the access token with appropriate adapter

Example

<?php

require 'vendor/autoload.php';

use Instagram\Adapters\Http\GuzzleAdapter;
use Instagram\Adapters\Storage\NativeSessionAdapter;
use Instagram\Security\Credentials;
use Instagram\Instagram;

$storage     = new NativeSessionAdapter();
$credentials = new Credentials([
    'client_id'     => 'YOUR-CLIENT-ID',
    'client_secret' => 'YOUR-CLIENT-SECRET',
    'redirect_uri'  => 'REDIRECT-URI
  ], $storage);

// You may provide additional scope as array of desired additional permissions
$loginUrl = $credentials->getLoginUrl(['basic', 'likes']);

Usage

<?php 

require 'vendor/autoload.php';

use Instagram\Adapters\Http\GuzzleAdapter;
use Instagram\Adapters\Storage\NativeSessionAdapter;
use Instagram\Security\Credentials;
use Instagram\Instagram;

$storage     = new NativeSessionAdapter();
$credentials = new Credentials([
    'client_id'     => 'YOUR-CLIENT-ID', 
    'client_secret' => 'YOUR-CLIENT-SECRET', 
    'redirect_uri'  => 'REDIRECT-URI
  ], $storage);
  
$adapter = new GuzzleAdapter($credentials->getToken());  
$factory = new Instagram($adapter);
  
  
$user = $factory->userClient();
var_dump($user->getInfo());

Issues

Any problems that may arise or for bug spottings please open up an [Issue case] (https://github.com/rockoo/InstagramAPI/issues)

统计信息

  • 总下载量: 43
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-06-29