Instagram api无法获得关注和关注_by

时间:2018-07-25 20:50:08

标签: instagram instagram-api

https://github.com/cosenary/Instagram-PHP-API

instagram.php此文件包括。

mycode.php

<php 
include_once(G5_PATH.'/instagram/src/Instagram.php');
use MetzWeb\Instagram\Instagram;
// initialize class
$instagram = new Instagram(array(
'apiKey' => 'a59129f1575c4af08eb7eb275c885b71',
'apiSecret' => 'c0fe8d2733e6440c9833df722c15499d',
'apiCallback' => 'http://nextgroup.cafe24.com/bbs/register_form.php' // must 
 point to success.php
 ));
// create login URL
$loginUrl = $instagram->getLoginUrl();

// receive OAuth code parameter
$code = $_GET['code'];
// check whether the user has granted access
if (isset($code)) {
// receive OAuth token object
$data = $instagram->getOAuthToken($code);
$username = $data->user->username;
// store user access token
$instagram->setAccessToken($data);
// now you have access to all authenticated user methods
$result = $instagram->getUser();
// create login URL
$loginUrl = $instagram->getLoginUrl();

// receive OAuth code parameter
$code = $_GET['code'];
// check whether the user has granted access
if (isset($code)) {
// receive OAuth token object
$data = $instagram->getOAuthToken($code);
$username = $data->user->username;
// store user access token
$instagram->setAccessToken($data);
// now you have access to all authenticated user methods
$result = $instagram->getUser();



} else {
// check whether an error occurred
if (isset($_GET['error'])) {
    echo 'An error occurred: ' . $_GET['error_description'];
}
}

?>

API正常调用。

<a class="login" href="<?php echo $loginUrl ?>">Login</a>

id : <?php echo $data->user->id ?>
username : <?php echo $data->user->username ?>
profile_picture : <img src="<?php echo $data->user->profile_picture ?>">
full_name : <?php echo $data->user->full_name ?>
bio : <?php echo $data->user->bio ?>
website : <?php echo $data->user->website ?>
is_business : <?php echo $data->user->is_business ?>

media : <?php echo $data->user->counts->media ?>
follows : <?php echo $data->user->counts->follows ?>
followed_by : <?php echo $data->user->counts->followed_by ?>

[id, username, profile_picture, full_name, bio, website]效果很好。

但是[[is_business, media, follows, followed_by] null值。

<?php echo $data->user->follows ?>一样。

我不知道原因。你能帮我吗?

0 个答案:

没有答案