有没有一种方法可以使用Graph API获取我Facebook好友的位置?
如果您想从用户的朋友那里获取所需信息,最快捷的方法是使用FQL方法:
$this->api->api(array('method'=>'fql.query','query'=>"SELECT uid,name,first_name,middle_name,last_name,pic_square,hometown_location,current_location,profile_url,email,website FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())"));
要查看所有表格及其对应列名的列表,请参阅:Facebook FQL 参考文档
FB.api('/me', function(response) {
var location = response.location.name;
});
FaceBook文档中包含了您所需的信息,其中包括示例代码和指南。您可以在以下链接中找到它:
http://developers.facebook.com/docs/guides/canvas
你可能会发现Graph API很有用:http://developers.facebook.com/docs/api
fql?q=SELECT locale,current_location from user where uid in(select uid2 from friend where uid1=me())
需要用户位置或好友位置权限
FB.api('/me', function(response) {
document.getElementById("UserLocation").innerHTML = response.location.name;
});
UserLocation
ID来调用任何HTML标签。例如:<div id="UserLocation"></div>