我试图从公共页面检索所有事件,而我只是得到一个空数组。它适用于Feed,我尝试登录并查看我的个人资料并获取活动,因此我不明白为什么不使用公共页面。
这是我的代码。有没有?
session_start();
require_once 'vendor/autoload.php';
require_once 'base_facebook.php';
require_once 'facebook.php';
use base_facebook;
use Facebook;
use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\AccessToken;
use Facebook\FacebookHttpable;
use Facebook\FacebookCurl;
use Facebook\FacebookCurlHttpClient;
use Facebook\GraphUser;
$facebook = new Facebook(array(
'appId' => '{app_id}',
'secret' => '{app_secret}',
"redirect_uri" => "http://localhost/fb/src/acme/app/facebookpoc.php",
'cookie' => true ));
// Graph API to request to EVENTS
$pageevents = $facebook->api("/" . "nike" . "/events?fields=name,description,privacy,end_time,location");
echo "<pre>";
print_r( $pageevents );
echo "</pre>";
// Loop for events
foreach($pageevents['data'] as $event) {
// Open up an fb-event div
echo "<div class=\"fb-event\">";
// Post start time of the event and its data
echo "<h2>The event starts on: " . date("jS M, Y", (strtotime($event['start_time']))) . "</h2>";
echo "<p> Name of the event: " . $event['name'] . "</p>";
if (isset($event['description'])) //Check if the event has a description concreted
{
echo "<p> Description of the event: " . $event['description'] . "</p>";
}
else echo "<p> Event has no description concreted </p>";
if (isset($event['location'])) //Check if the event has a location concreted
{
echo "<p> Location of the event: " . $event['location'] . "</p>";
}
else echo "<p> The event has no location concreted </p>";
if (isset($event['end_time'])) //Check if the event has ending time
{
echo "<p> The event ends at: " . date("jS M, Y", (strtotime($event['end_time']))) . "</p>";
}
else echo "<p> The ending time of the event hasn't been concreted </p>";
if($event['privacy'] != "OPEN") // Check the current privacy of the event
{
echo "<p> <strong>The event is not fully public!! </p> </strong>";
}
else echo "<p> The event is <strong>fully public!</strong> </p>";
// Close fb-event div
echo "</div>";
}
它输出:
阵 ( [data] =&gt;排列 ( ) )
先谢谢,但我真的不知道为什么会这样......