如何取得facebook 頭像?甚至保存到本機來?

關於facebook 登入!

clipboard.png

印出 getPicture() 後是這樣的格式:

{"height":50,"is_silhouette":false,"url":"https:\/\/lookaside.facebook.com\/platform\/profilepic\/?asid=xxx&height=50&width=50&ext=xxx&hash=xxsxsxsxsxs","width":50}

我要怎麼直接抓出 url key的value?

阅读 3.5k
1 个回答
$me = $response->getGraphUser();
$pictureJson = $me->getPicture();
$pictureItem = json_decode($pictureJson,true);
echo $pictureItem['url'];

大概就是把这个json字符串转换成PHP数组。然后再处理。

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题