使用Instagram Basic Display API获取用户媒体

使用Instagram Basic Display API获取用户媒体,instagram,instagram-api,instagram-graph-api,Instagram,Instagram Api,Instagram Graph Api,我想通过Instagram Display API从帐户中检索照片,但在文档中找不到任何内容 最接近这一点的是,它只允许您恢复连接到API的人的照片。但是,我希望能够从用户名或标签中恢复任何人的照片 GET /me?fields={media}&access_token={access-token} 我也发现了这一点,但没有解释如何从用户名中获取某人的用户id GET https://graph.instagram.com/{user-id}/media?access_token={a

我想通过Instagram Display API从帐户中检索照片,但在文档中找不到任何内容

最接近这一点的是,它只允许您恢复连接到API的人的照片。但是,我希望能够从用户名或标签中恢复任何人的照片

GET /me?fields={media}&access_token={access-token}
我也发现了这一点,但没有解释如何从用户名中获取某人的用户id

GET https://graph.instagram.com/{user-id}/media?access_token={access-token}
我找到了一种不用Instagram API(源代码)的方法,但我担心他们会更改代码,因此此解决方案将不再有效,因此我希望使用Instagram API

        $html = file_get_contents('https://instagram.com/' . $username . '/');
        preg_match('/_sharedData = ({.*);<\/script>/', $html, $matches);
        $profil_data = json_decode($matches[1])->entry_data->ProfilePage[0]->graphql->user;
        $data_edges = $profil_data->edge_owner_to_timeline_media->edges;

        foreach ($data_edges as $key => $value) {
            $img_url = $value->node->display_url;
            echo "<img src=" . $img_url . ">";
        }
$html=file\u get\u contents('https://instagram.com/“.$username./”);
preg_match('/_sharedData=({.*);/',$html,$matches);
$profil_data=json_decode($matches[1])->entry_data->ProfilePage[0]->graphql->user;
$data\u edges=$profile\u data->edge\u owner\u to\u timeline\u media->edges;
foreach($data_边为$key=>$value){
$img\u url=$value->node->display\u url;
回声“;
}

提前感谢。

您好,我在这里找到了本教程,但这很麻烦,我宁愿继续更改代码,也不愿继续做这件事

,所以我最终放弃了使用API,而是使用了这个库。

目前无法通过Instagram Basic Display API从未经身份验证的用户处获取公共数据。