Instagram API - 返回的媒体被切断

Instagram API - Media returned is cut off

我到处搜索,但没有人link解释或修复为什么会发生这种情况。

每当我向 Instagram 发出端点请求以获取图片时,url 提供的大部分图片都会被截断 - 与 Instagram 上的原始 post 相比,并不是整张照片都在那里.在我看来,也许从逻辑上讲,被切断的图像是不完全正方形的图像。

有没有什么方法可以得到完整的图像,而不需要裁剪以使其适合一个精确的正方形?

谢谢。

编辑:刚刚意识到开发人员控制台中有一个非方形媒体选项,但是我检查了这个但它似乎不起作用。

已解决。虽然这确实有效,但令人失望的 Instagram 非方形媒体功能并没有达到预期效果。

$image_url = $insta_liked_array['data'][$image_key]['images']
['standard_resolution']['url'];

//parse url to get last segment before image name

$segments = explode('/', parse_url($image_url, PHP_URL_PATH));
$segment_removal = $segments[5];

//New Url without the segment
$image_url_dynamic = str_replace("/" . $segment_removal,"",$image_url);

echo $image_url_dynamic;

编辑: 有时以上可能不会按预期执行,我已经经历了制作一些东西的麻烦...26 行代码都是因为 instagram 无法修复一个简单的复选框!

//'/e35/c' is a common string in each url, so from this we can take 
//away the /c... section using this info
//whatever index [e35] is, check if the next index has c as the first 
//letter, if so, remove that part

echo "Exploding url, checking for non-square media...\n\n";
$segments = explode('/', parse_url($image_url, PHP_URL_PATH));

if(in_array('e35', $segments)){
//get the index of e35
$e35_index = array_search('e35', $segments);
//if the letter 'c' is in the next seg, remove it
// to check if 'c' is in the next segment
$c_segment = $segments[$e35_index + 1];

if (strpos($c_segment, 'c') !== false) {
echo "Non square media resolve in progress...\n\n";
//get rid of that section +backslash, (replace with nothing)
$image_url = str_replace("/" . $c_segment,"",$image_url);
echo "New url has been made...\n\n\n\n" . $image_url;
}
elseif(strpos($c_segment, 'c') === false){
echo "Square media detected, no need to remove a segment...\n\n";
$image_url = $image_url;
}
else {
echo "An error occured";
}
}
else{
echo "An error occured - url should contain 'e35' string";
}

API 的客户端配置页面中有一个选项可以将 API 设置为 return 非方形媒体,它在迁移选项卡中: