【问题标题】:Testing if user has posted a facebook profile picture and if so, retrieving it?测试用户是否发布了 Facebook 个人资料图片,如果是,则检索它?
【发布时间】:2011-05-25 14:05:31
【问题描述】:

验证用户是否已放入 facebook 个人资料图片(即非默认图片)的正确方法是什么,如果是,则检索它?

这个:How to determine if a Facebook user has uploaded a profile picture or its default?讲了一个方法,但是作者自己说是个坏方法:

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);
}

【问题讨论】:

    标签: facebook api detect image facebook-fql


    【解决方案1】:

    如果用户有个人资料照片,可以通过http://graph.facebook.com/<facebook username>/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 决定改变它之前都可以使用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-05-21
      • 1970-01-01
      • 2011-07-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多