【问题标题】:Get Instagram Feeds using username/user id使用用户名/用户 ID 获取 Instagram 订阅源
【发布时间】:2018-04-25 10:29:59
【问题描述】:
【问题讨论】:
标签:
php
codeigniter
instagram
instagram-api
【解决方案1】:
跟着我的脚步
首先,您需要在 Instagram 开发者网站上注册您的应用程序并获取您的Client ID 和Client Secret 代码,然后您必须使用Client ID 和Client Secret 创建access_token
访问此处:https://elfsight.com/blog/2016/05/how-to-get-instagram-access-token/ 用于创建 Client ID、Client Secret 和 access_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