aainc/instagram

Instagram PHP SDK

1.5 2017-02-22 02:30 UTC

This package is not auto-updated.

Last update: 2024-09-28 20:44:04 UTC


README

描述

Instagram API 是一个 Instagram API 调用库。

要求

  • PHP 5.6 或更高版本
  • Guzzle 6.2
  • 已注册的 Instagram 应用程序

开始使用

安装

composer require aainc/instagram

初始化类

<?php
use \Munouni\Instagram\Instagram;
$instagram = new Instagram([
    'client_id'     => 'YOUR_CLIENT_KEY',
    'client_secret' => 'YOUR_CLIENT_SECRET',
    'redirect_uri'  => 'YOUR_APP_REDIRECT_URI'
]);

$loginUrl = $instagram->getOAuthUrl();

// $loginUrl = $instagram->getOAuthUrl(['basic', 'public_content', 'follower_list', 'comments', 'relationships', 'likes']);

获取访问令牌

<?php
$code = $_GET['code'];
$token = $instagram->getOAuthToken($code);

调用 API

<?php
use \Munouni\Instagram\Instagram;
$instagram = new Instagram(['access_token' => 'YOUR_ACCESS_TOKEN']);
$response = $instagram->sendRequest('GET','/users/self');
$response = $instagram->sendRequest('GET','/tags/{tag-name}/', ['{tag-name}' => 'ミンゴス']);
$response = $instagram->sendRequest('GET','/tags/search',['q' => 'ミンゴス']);

分页

<?php
use \Munouni\Instagram\Instagram;
$instagram = new Instagram(['access_token' => 'YOUR_ACCESS_TOKEN']);
$response = $instagram->sendRequest('GET','/tags/{tag-name}/media/recent',['{tag-name}' => 'ミンゴス']);
$nextResponse = $instagram->next($response);

许可证

MIT 许可证

版权所有 (c) 2017 Allied Architects Co.,Ltd.

在此特此授予任何获得本软件及其相关文档副本(以下简称“软件”)的人士,免费、无限制地处理该软件的权利,包括但不限于使用、复制、修改、合并、发布、分发、再许可和/或出售软件副本,并允许将软件提供给其他人,使其有权这样做,但受以下条件限制:

上述版权声明和本许可声明应包含在软件的所有副本或主要部分中。

本软件按“原样”提供,不提供任何形式的保证,无论是明示的、暗示的,还是关于适销性、特定用途适用性或非侵权的保证。在任何情况下,作者或版权所有者均不对任何索赔、损害或其他责任承担责任,无论是基于合同、侵权或其他原因,源自、因或与软件或软件的使用或其他方式有关。