dulabs / instagram
Instagram OAuth 2.0 客户端
1.0.0
2016-02-04 05:34 UTC
Requires
- php: >=5.5.0
Requires (Dev)
- mockery/mockery: ~0.9
- phpunit/phpunit: ~4.1
- squizlabs/php_codesniffer: ~2.0
This package is not auto-updated.
Last update: 2024-09-14 19:19:56 UTC
README
新 Instagram API 包装器
安装
下载 master 分支 https://github.com/dulabs/new-instagram-api/archive/master.zip
查看 index.php 以使用 Instagram 进行用户认证。
查看 callback.php 以获取访问令牌。
登录
require_once(__DIR__.'/../vendor/autoload.php'); use Dulabs\Instagram\OAuthManager as OAuth; $config['api_key'] = ""; $config['api_secret'] = ""; $config['callback_url'] = "https:///instagram/demo/callback.php"; $config['response_type'] = OAuth::RESPONSE_TYPE_CODE; $oauth = new OAuth(); // initialiaze config $oauth->setConfig($config); // define scopes $loginurl = $oauth->login(['basic','public_content','follower_list']); header("location: ".$loginurl);
回调
require_once(__DIR__.'/../vendor/autoload.php'); use Dulabs\Instagram\OAuthManager as OAuth; $config['api_key'] = ""; $config['api_secret'] = ""; $config['callback_url'] = "https:///instagram/callback.php"; $config['response_type'] = OAuth::RESPONSE_TYPE_CODE; // We need to configure OAuth $oauth = new OAuth(); $oauth->setConfig($config); if(isset($_GET['code']) && !empty($_GET['code'])) { $token = $oauth->getAccessToken(); setcookie("instagram_token",$token,time()+3600); header("location: demo.php"); }