Instagram 最新 post API 突然停止工作

Instagram Latest post API suddenly stopped working

我的 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 已于 2018 年 4 月 6 日禁用以下功能(即 已弃用 关注 API 的功能):

关注者列表 - 阅读关注者列表和 followed-by 用户

关系 - 代表用户关注和取消关注帐户

评论 Public 内容 - post 并代表用户在 public 媒体

上删除评论

喜欢 - 代表用户喜欢和不喜欢媒体

订阅 - 在媒体 posted

时接收通知

用户信息 - 搜索和查看用户的 public 内容 关于通过主题标签和位置返回的 Public 内容的一些信息 搜索 - 姓名、简历、评论、评论者、关注者计数、关注者计数、 Post 计数和头像

访问令牌工作正常。但是 post 在网站上是看不到的。我使用的代码如下:

$access_token = get_field('instagram_access_token', 'option') ? get_field('instagram_access_token', 'option') : '';
               $url = "https://api.instagram.com/v1/users/self/?access_token={$access_token}";

                $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;

您没有正确解析响应。例如,在该响应中没有 user->media->nodes。您将需要检查从端点获得的响应,然后正确解析它以获取图像:

$access_token = get_field('instagram_access_token', 'option') ? get_field('instagram_access_token', 'option') : '';
$url = "https://api.instagram.com/v1/users/self/media/recent?access_token={$access_token}";

$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->data;

$text = $data[0]->caption->text;

$created_time = $data[0]->created_time;

$images = $data[0]->images->standard_resolution->url;