【发布时间】:2018-04-08 08:46:06
【问题描述】:
我的 instagram 提要运行良好,但已停止运行。我正在努力寻找解决方案。首先,我假设问题与 SSL 有关,我什至为我的网站获得了 SSL 证书。但似乎不起作用。任何帮助或建议表示赞赏。输出显示在 instagram 上发布的最新图片,现在什么都没有。1
<div class="col-xs-12 col-sm-6 col-md-5 no-padding">
<div class="insta_img">
<?php
$instagram_id = get_field('instagram_id', 'option') ? get_field('instagram_id', 'option') : '';
$access_token = get_field('instagram_access_token', 'option') ? get_field('instagram_access_token', 'option') : '';
$url = "https://www.instagram.com/{$instagram_id}/?__a=1";
curl_close($ch);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$json = curl_exec($ch);
curl_close($ch);
$data = json_decode($json);
$data = $data->user->media->nodes;
$text = $data[0]->caption;
$created_time = $data[0]->date ;
$images = $data[0]->thumbnail_src;
/
?>
<img src="<?php echo $images; ?>" alt="instagram"/>
<div class="insta_content"><?php echo $text; ?>
<dt><?php echo date('d/m/Y', $created_time); ?></dt>
</div>
</div>
【问题讨论】:
-
Instagram 最近由于 Facebook 隐私事件对其 API 进行了一些更改。您可能需要查看他们的新闻或更新日志。
-
@RuChernChong 感谢您的回复。我会看看他们的变更日志。我希望他们能尽快找到解决方案。
-
您没有使用官方 API。您基本上只是在抓取 URL。所以你不应该依赖这种方法来总是给你一个可预测的结果。另外,你为什么要引用一个你从不使用的访问令牌?
-
@hermanschutte 感谢您的回复。我已经评论了那条线。我正在尝试不同的网址,所以在发帖之前我忘了评论它。正如您提到的,它不是官方 API,我也注意到了,API 是由其他人创建的。有没有办法使用官方 API 从 Instagram 帐户获取最新帖子?
-
@sundasmunir 是的,您正在寻找的端点是这个:
https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN。 Instagram API 文档中提供了更多信息:instagram.com/developer/endpoints
标签: json api ssl curl instagram