Facebook PHP SDK检索用户的当前位置

时间:2012-12-17 17:47:13

标签: php arrays facebook

到目前为止,我已经尝试过:

$facebook->api('/me', 'get', array("fields"=>"location"));

返回:

Array ( [location] => Array ( [id] => 107847249250173 [name] => Cambridge, Cambridgeshire ) [id] => 1234567890 )

如果我有必要的权限,我怎么能以一种可以插入数据库的格式回显[name]位(所以输出是#34; Cambridge,Cambridgeshire")? / p>

1 个答案:

答案 0 :(得分:2)

$data = $facebook->api('/me', 'get', array("fields"=>"location"));
echo $data['location']['name'];