Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何向Graph Api发送请求并获取事件数据?_Php_Facebook Graph Api - Fatal编程技术网

Php 如何向Graph Api发送请求并获取事件数据?

Php 如何向Graph Api发送请求并获取事件数据?,php,facebook-graph-api,Php,Facebook Graph Api,我是图形api/php的初学者。我想根据页面id等获取事件数据。当我将url粘贴到浏览器中时,它返回json数据,但当我使用curl或file_get_contents()时;方法返回“Null”。发送请求和获得响应的正确方式是什么。这是我的基本代码,除此之外,我没有使用任何类型的包含文件等 $json_link = "https://graph.facebook.com/getwellgabby/events/attending/?fields=id,name,description,time

我是图形api/php的初学者。我想根据页面id等获取事件数据。当我将url粘贴到浏览器中时,它返回json数据,但当我使用curl或file_get_contents()时;方法返回“Null”。发送请求和获得响应的正确方式是什么。这是我的基本代码,除此之外,我没有使用任何类型的包含文件等

$json_link = "https://graph.facebook.com/getwellgabby/events/attending/?fields=id,name,description,timezone,start_time,cover&access_token=206516302813755|lRnrKAiu3Z......&since=1356998400&until=1483228800";

file_get_contents($json_link);

$obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);

 var_dump($json);
结果:布尔值(假)

正如您在文档中看到的,获取活动参与者的正确方法是使用活动ID:

https://graph.facebook.com/{event-id}/attending?access_token=xxx
您不能在一个API调用中获得所有事件的所有与会者,您必须逐个事件进行此操作。在使用任何PHP代码之前,请在中进行测试


顺便说一句,您应该使用
CURL
而不是
file\u get\u contents
。PHPSDK也使用了
CURL

谢谢您的回复……但我不明白这个问题。无论我在请求中发送什么,比如如果我发送简单的请求,它应该返回基本信息,然后在curl响应中返回false,如果我将此url粘贴到urlbar,它将返回正确的结果。阅读一些关于curl的教程,您可以激活调试模式,您可以显示标题等等。了解如何在php中调试东西是非常重要的。但卷曲部分只是一个旁注。