我到处搜索过,但没有一个链接可以解释或解释为什么会这样。
每当我向Instagram发送端点请求以获取图片时,大多数图片都会被截断 - 与Instagram上的原始帖子相比,并不是整张照片都在那里。在我看来,也许从逻辑上看,被切断的图像是一个不完全正方形的图像。
有没有办法获得完整的图像,没有裁剪到适合它的方形?
谢谢。
编辑:刚刚意识到开发人员控制台中有一个非方形媒体选项,但是我已经选中了这个选项,但它似乎没有用。
答案 0 :(得分:0)
解决。虽然这确实有效,但令人失望的是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";
}
答案 1 :(得分:0)