Where do I find the Instagram media ID of a image

后端 未结 15 1414

I\'m am looking for the MediaID of an Instagram image which has been uploaded. It should look like

1234567894561231236_33215652

15条回答
  •  遥遥无期
    2020-12-22 19:56

    You can use the shortcode media API from instagram. If you use php you can use the following code to get the shortcode from the image's URL:

    $matches = [];
    
    preg_match('/instagram\.com\/p\/([^\/]*)/i', $url, $matches);
    
    if (count($matches) > 1) {
        $shortcode = $matches[1];
    }
    

    Then send a request to the API using your access token (Replace ACCESS-TOKEN with your token)

    $apiUrl = sprintf("https://api.instagram.com/v1/media/shortcode/%s?access_token=ACCESS-TOKEN", $shortcode);
    

提交回复
热议问题