Get List of Restaurants from New York city using Facebook Graph API

半世苍凉 提交于 2020-04-11 00:58:49

问题


I want to get the list of all the restaurant pages that are based in New York using Facebook Graph API. I have downloaded the PHP-SDK and now I am stuck with this problem. I only need the id of the restaurant pages.

<?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;
}

?>

Now as you can see in the above code I get all types of category(like APP, Food & Beverage, Company, etc) and from different parts of the world. I only want restaurants from New York and really don't know how to filter the result.

Any help will really be appreciated.


回答1:


Replace this url,

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

New York center latitude=40.714623 & longitude=-74.006605. An access token is required to request this resource.

May this help you.



来源:https://stackoverflow.com/questions/10258589/get-list-of-restaurants-from-new-york-city-using-facebook-graph-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!