Instagram的GET /用户/用户ID不返回任何数据? [英] Instagram GET /users/user-id Not returning any data?

查看:246
本文介绍了Instagram的GET /用户/用户ID不返回任何数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想显示的追随者我的帐户中我的PHP页面,由于某种原因,数量,当我尝试使用的 https://api.instagram.com/v1/users/ {$用户ID} /如下?=的access_token $ {}的accessToken线fetchData,我没有得到任何信息。

I'm trying to display the number of followers my account has in my php page and for some reason when I try to use the https://api.instagram.com/v1/users/{$userid}/follows?access_token={$accessToken} fetchData line, I get no information.

<?php    

    $userinfo = fetchData("https://api.instagram.com/v1/users/{$userid}/follows?access_token={$accessToken}");
    $userinfo = json_decode($userinfo);


    foreach($userinfo->data as $profile) {
        $followers = $profile->counts->follow_by;
        echo "Followed by: ".$followers;
    }
?>   

但是,如果我用同样的code具有不同的端点的命令,并调用不同的数据,它的伟大工程(如下面)

But if I use the same code with a different endpoint command and call different data, it works great (like below)

<?php    

    $userinfo = fetchData("https://api.instagram.com/v1/users/self/feed?access_token={$accessToken}");
    $userinfo = json_decode($userinfo);


    foreach($userinfo->data as $profile) {
        $followers = $profile->likes->count;
        echo "Followed by: ".$followers;
    }
?>   

任何想法,我可能做错了吗?

Any idea what I may be doing wrong?

感谢

推荐答案

用户/用户ID {}​​ /如下端点不会返回您的个人资料的任何数据。它只返回那用户配置文件数组您按照

The users/{userid}/follows endpoint will not return any data on your profile. It only returns an array of user profiles that you follow.

最快捷的方式的方式来访问你的追随者数是使用用户/用户ID {}​​ 端点:

The quickest way way to access your followers count is to use the users/{userid} endpoint:

$userinfo = fetchData("https://api.instagram.com/v1/users/YOUR_USER_ID?access_token=YOUR_ACCESS_TOKEN");
$userinfo = json_decode($userinfo);

$followers = $userinfo['data']['counts']['followed_by'];

echo "Folled by: " . $followers . " people";

此外,以供将来参考,我强烈建议您使用的Instagram的API控制台测试您的来电。这样,你可以看到正在从每次调用返回的数据,这样就可以正确地访问它。

Also, for future reference, I highly recommend you test your calls using Instagram's API Console. That way you can see what data is being returned from each call, so that you can access it correctly.

这篇关于Instagram的GET /用户/用户ID不返回任何数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆