问题描述
|
验证用户是否已放入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);
}
解决方法
如果用户有个人资料照片,则可以通过ѭ1accessed访问。例如,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决定对其进行更改后,它才能起作用。