julionc / instagram
此包已被放弃且不再维护。未建议替代包。
Instagram API 的 PHP 库
dev-master
2015-03-22 05:00 UTC
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ~5.2
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2020-01-28 10:07:01 UTC
README
Instagram API 的 PHP 库
目录
安装
使用 composer
{
"require": {
"julionc/instagram": "dev-master"
}
}
如何使用
require_once('vendor/autoload.php'); $config = array( 'client_id' => 'YOUR_CLIENT_ID', 'client_secret' => 'YOUR_CLIENT_SECRET', 'redirect_uri' => 'CALLBACK_URL', 'scope' => array('basic') ); $client = new Instagram\Auth($config); // In view, get the Authorize URL $client->authorize_url();
// profile.php // Preload the settings and capture the access code (Callback step). if (!$access_token) { $client = new Instagram\Auth($config); $client->requestAccessToken($access_code); $_SESSION['access_token'] = $client->getAccessToken(); } $instagram = new \Instagram\Instagram($access_token, 'secret_key_here');
如果您不想在代码中放置您的客户端凭据(可以理解),只需将其设置为环境变量 instagram.client_id
和 instagram.client_secrect
。因此 php-instagram 将自动获取它们。请参阅 example
文件夹。
端点
用户
$instagram = new \Instagram\Instagram($access_token); // Get basic information about a user. $user = $instagram->user->info(); // See the authenticated user's feed. $feed = $instagram->user->feed(); // Get the most recent media published by a user. $media = $instagram->user->media();