加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

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

发布时间:2020-12-13 17:19:04 所属栏目:PHP教程 来源:网络整理
导读:我想使用Facebook Graph API获取位于纽约的所有餐厅页面的列表.我已经下载了 PHP-SDK,现在我遇到了这个问题.我只需要餐馆页面的ID. ?php $url = "https://graph.facebook.com/search?q=restauranttype=page"; $result = file_get_contents($url,true); $resu
我想使用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,食品和饮料,公司等)以及来自世界各地的所有类别.我只想要来自纽约的餐馆,真的不知道如何过滤结果.

任何帮助将非常感激.

解决方法

替换此网址,

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

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

愿这对你有所帮助.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读