测试用户是否发布了 Facebook 个人资料图片,如果是,是否检索它?
验证用户是否已放入 Facebook 个人资料图片(即非默认图片)的正确方法是什么?如果是,则检索它?
这个: 如何判断Facebook用户上传的是个人资料图片还是默认的?讲了一种方法,但作者自己说这是一个不好的方法:
public static function hasProfilePicture($fbuid)
{
/* Really stupid method to test if Facebook user has real profile picture
* based on FB returning a gif when you request a large photo.
* Use with care - for every profile there's an outgoing request! */
$r = get_headers("http://graph.facebook.com/$fbuid/picture?type=square");
return !array_search("Content-Type: image/gif",$r);
}
What is the correct way of verifying that a user has put in a facebook profile picture (ie the non-default one), and if so, to retrieve it?
This: How to determine if a Facebook user has uploaded a profile picture or its default? talks about a method, but the author himself says that its a bad method:
public static function hasProfilePicture($fbuid)
{
/* Really stupid method to test if Facebook user has real profile picture
* based on FB returning a gif when you request a large photo.
* Use with care - for every profile there's an outgoing request! */
$r = get_headers("http://graph.facebook.com/$fbuid/picture?type=square");
return !array_search("Content-Type: image/gif",$r);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果用户有个人资料照片,则可以通过
http://graph.facebook.com//picture
访问它。例如, http://graph.facebook.com/gauravgupta.in/picture 重定向到特定的 URL 并显示我的 Facebook 个人资料图片。但是,如果用户没有个人资料图片,上述 URL 将被重定向到标准占位符图像的 URL,当前为 http://profile.ak.fbcdn.net/static-ak/rsrc.php/v1/yo/r/UlIqmHJn- SK.gif
这绝对不是一个可靠的方法,但在 Facebook 决定改变它之前它会一直有效。
If a user HAS a profile photo, it can be accessed via
http://graph.facebook.com/<facebook username>/picture
. For example, http://graph.facebook.com/gauravgupta.in/picture redirects to a specific URL and shows my Facebook profile picture.However, if a user does NOT have a profile picture, the above URL gets redirected to the URL of the standard placeholder image, which is currently http://profile.ak.fbcdn.net/static-ak/rsrc.php/v1/yo/r/UlIqmHJn-SK.gif
It's definitely not a reliable way, but will work till Facebook decides to change it.