使用用户名/用户 ID 获取 Instagram 订阅源

Posted

技术标签:

【中文标题】使用用户名/用户 ID 获取 Instagram 订阅源【英文标题】:Get Instagram Feeds using username/user id 【发布时间】:2018-04-25 10:29:59 【问题描述】:

我之前用过

https://www.instagram.com/graphql/query/?query_id=17888483320059182&variables=$result

现在从这个月开始,因为 instagram 已经改变了那里的 api,我无法获得提要。 任何建议都会有所帮助

【问题讨论】:

你能解决这个问题吗?我们遇到了同样的问题。 【参考方案1】:

跟着我的脚步

首先,您需要在 Instagram 开发者网站上注册您的应用程序并获取您的Client IDClient Secret 代码,然后您必须使用Client IDClient Secret 创建access_token

访问此处:https://elfsight.com/blog/2016/05/how-to-get-instagram-access-token/ 用于创建 Client IDClient Secretaccess_token

然后,在你的控制器函数中添加以下代码

$access_token = 'xxxxxxxxxx.xxxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // your access_token will be this format
$count_feed = 2; // how many feed want to load

$requestURL = 'https://api.instagram.com/v1/users/self/media/recent?access_token='.$access_token.'&count='.$count_feed;
$ch = curl_init();
curl_setopt_array($ch, array(        
    CURLOPT_URL => $requestURL,
    CURLOPT_HEADER  => false,
    CURLOPT_RETURNTRANSFER => 1
));
$json_response = curl_exec($ch);
curl_close($ch);
$insta_feeds = json_decode($json_response, true);

_e($insta_feeds); // $insta_feeds['data'] will return feed

您可以使用 Instagram 库 获取供稿。在这里查看图书馆:https://github.com/suhindra/CodeIgniter-Instagram-API

【讨论】:

以上是关于使用用户名/用户 ID 获取 Instagram 订阅源的主要内容,如果未能解决你的问题,请参考以下文章

如何从 instagram messenger webhook 获取 instagram 用户名

使用 Instagram API 获取用户的位置

我无法通过 instagram API 获取 instagram 用户的媒体详细信息

用于获取用户公共内容的新 instagram api?

Instagram Api 获取所有未关注用户的列表

获取授权用户的头像(Instagram Basic Display API)