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

Rog*_*ger 4 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;
}

?>
Run Code Online (Sandbox Code Playgroud)

现在您可以在上面的代码中看到我获得所有类型的类别(如APP,Food&Beverage,Company等)以及来自世界各地的所有类别.我只想要来自纽约的餐馆,真的不知道如何过滤结果.

任何帮助将非常感激.

Ton*_*ark 5

替换此网址,

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

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

愿这对你有所帮助.