测试用户是否发布了 Facebook 个人资料图片,如果是,是否检索它?

发布于 2024-11-09 22:56:55 字数 724 浏览 8 评论 0原文

验证用户是否已放入 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

瞳孔里扚悲伤 2024-11-16 22:56:55

如果用户有个人资料照片,则可以通过 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文