kozz/instagram-client
Composer 安装命令:
composer create-project kozz/instagram-client
包简介
Instatram Client
关键字:
README 文档
README
Install and run tests
composer install
vendor/bin/phpunit
# with coverage
vendor/bin/phpunit --coverage-html=build/logs
Usage
OAuth
Step 1
$client = new InstagramAuth(new AuthConfig(env("I_CLIENT_ID"), env("I_CLIENT_SECRET"), "http://localhost/auth")); $url = $client->getOAuthUrl(); // $url === 'https://api.instagram.com/oauth/authorize/?client_id=d2cbeff4792242f7b49ea65f984a1237&response_type=code&redirect_uri=http://localhost/auth&scopes=basic
Step 2
$client = new InstagramAuth(new AuthConfig(env("I_CLIENT_ID"), env("I_CLIENT_SECRET"), "http://localhost/auth")); $token = $client->retrieveOAuthToken($_GET['code']);
Subscriptions
Create Subscription
Step 1
Create public controller and action, which would handle GET request. Instagramm will call it during creating subscription:
class SomeController{ function actionCallbackGet{ echo $_GET['hub.challenge']; } }
Step 1 Create Subscription:
$client = new InstagramClientUnauthorized(new AuthConfig(env("I_CLIENT_ID"), env("I_CLIENT_SECRET"), "http://localhost/auth")); /** @var CreateSubscriptionResponse $response */ $response = $client->call(new CreateSubscriptionRequest([ 'object' => 'user', 'aspect' => 'media', 'callback_url' => 'http://yoursite.me/some/callback' ]));
Get subscriptions
$client = new InstagramClientUnauthorized(new AuthConfig(env("I_CLIENT_ID"), env("I_CLIENT_SECRET"), "http://localhost/auth")); /** @var GetSubscriptionsResponse $response */ $response = $client->call(new GetSubscriptionsRequest());
Delete subscription(s)
$client = new InstagramClientUnauthorized(new AuthConfig(env("I_CLIENT_ID"), env("I_CLIENT_SECRET"), "http://localhost/auth")); /** @var DeleteSubscriptionsResponse $response */ $response = $client->call(new DeleteSubscriptionsRequest([ 'object'=>'user' ])); $response = $client->call(new DeleteSubscriptionsRequest([ 'object'=>'all' ])); $response = $client->call(new DeleteSubscriptionsRequest([ 'id'=>1 ]));
Handle subscription request from the Instagram
$config = new AuthConfig(env("I_CLIENT_ID"), env("I_CLIENT_SECRET"), "http://localhost/auth"); $reactor = new SubscriptionReactor($config); $reactor->registerCallback("user", function(RealTimeSubscription $subscription){ // Do something }); $reactor->process($this->json, $_SERVER['HTTP_X_HUB_SIGNATURE']); // $_SERVER['HTTP_X_HUB_SIGNATURE'] - it is just header "X-Hub-Signature"
统计信息
- 总下载量: 209
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-05-14