Instagram基本显示API如何在PHP中获得最新的图像?

ykejflvf  于 2022-12-02  发布在  PHP
关注(0)|答案(1)|浏览(108)

Instagram如何获取最新的Instagram图片现在它正在获取最旧的图片
我在用那个密码-

function insta( $api_url ){
    $connection_c = curl_init(); // initializing
    curl_setopt( $connection_c, CURLOPT_URL, $api_url ); // API URL to connect
    curl_setopt( $connection_c, CURLOPT_RETURNTRANSFER, 1 ); // return the result, do not print
    curl_setopt( $connection_c, CURLOPT_TIMEOUT, 20 );
    $json_return = curl_exec( $connection_c ); // connect and get json data
    curl_close( $connection_c ); // close connection
    return json_decode( $json_return ); // decode and return
}
$return = insta("https://graph.instagram.com/me/media?fields=id,caption&access_token=xyz");

为什么只有25张图片
这是我遵循的文档- 1 -https://developers.facebook.com/docs/instagram-basic-display-api/getting-started
2个

m2xkgtsf

m2xkgtsf1#

$connection_c = curl_init(); // initializing
curl_setopt( $connection_c, CURLOPT_URL, "https://graph.instagram.com/me/media?fields=id&access_token=TOKEN" );
curl_setopt( $connection_c, CURLOPT_RETURNTRANSFER, 1 ); 
curl_setopt( $connection_c, CURLOPT_TIMEOUT, 20 );
$json_return = curl_exec( $connection_c );
curl_close( $connection_c );
$dataArray= json_decode( $json_return, true ); 

        foreach($dataArray["data"] as $key=>$val)
        {

            $connection_c = curl_init(); // initializing
            curl_setopt( $connection_c, CURLOPT_URL, "https://graph.instagram.com/".$val["id"]."?fields=id,media_type,media_url,username,timestamp&access_token=TOKEN" ); // API URL to connect
            curl_setopt( $connection_c, CURLOPT_RETURNTRANSFER, 1 ); // return the result, do not print
            curl_setopt( $connection_c, CURLOPT_TIMEOUT, 20 );
            $json_return = curl_exec( $connection_c ); // connect and get json data
            curl_close( $connection_c ); // close connection
            $mediaArray= json_decode( $json_return, true ); // decode and return
            var_dump($mediaArray);
        }

相关问题