使用Facebook Graph API获取纽约市的餐馆列表

时间:2012-04-21 11:43:32

标签: php facebook-graph-api

我希望使用Facebook Graph API获取所有位于纽约的餐厅页面列表。我已经下载了PHP-SDK,现在我遇到了这个问题。我只需要餐馆页面的id。

<?php
  $url = "https://graph.facebook.com/search?q=restaurant&type=page";
  $result = file_get_contents($url,true);
  $result = json_decode($result);
  //print_r($result);
  $i = 25;
  for($a=0;$a<$i;$a++) {
$restaurantName = $result->data[$a]->name;
$restaurantCategory = $result->data[$a]->category;
$restaurantPage_id = $result->data[$a]->id;
}

?>

现在您可以在上面的代码中看到,我可以从世界各地获得所有类别的类别(如APP,食品和饮料,公司等)。我只想要来自纽约的餐馆而且真的不知道如何过滤结果。

真的很感激任何帮助。

1 个答案:

答案 0 :(得分:5)

替换此网址

$url ="https://graph.facebook.com/search?q=restaurant&type=place&center=40.714623,-74.006605&distance=16000&access_token=`Your_Access_Token`";

纽约中心纬度= 40.714623&amp;经度= -74.006605。 需要访问令牌来请求此资源。

愿这对你有所帮助。

相关问题