基雷是正确的,但对你的使用情况更好的解决方案将是如下:
// get the headers from the source without downloading anything
// there will be a location header wich redirects to the actual url
// you may want to put some error handling here in case the connection cant be established etc...
// the second parameter gives us an assoziative array and not jut a sequential list so we can right away extract the location header
$headers = get_headers('https://graph.facebook.com/1489686594/picture',1);
// just a precaution, check whether the header isset...
if(isset($headers['Location'])) {
$url = $headers['Location']; // string
} else {
$url = false; // nothing there? .. weird, but okay!
}
// $url contains now the url of the profile picture, but be careful it might very well be only temporary! there's a reason why facebok does it this way ;)
// the code is untested!
是的,你可以做到这一点http://w-shadow.com/blog/2008/07/05/how-to-get-重定向url-in-php/ – Ben 2010-08-20 22:14:56
哦,非常感谢Ben,它完美的工作。我正在使用它,以便当用户在我的网站上与Facebook连接时,我可以获取他们的Facebook个人资料图片,使其成为他们的默认图片。 谢谢:) – kire 2010-08-20 22:27:17
@kire,不FaceBook开发人员API给你一个正式的解决方案来做到这一点?我从来没有用过它,但我认为他们这样做。通常在没有协议的情况下接管其他网站资源可能会导致知识产权禁令。 – Ben 2010-08-20 22:33:09