i want to get all attending events on my profile on Facebook. i found this interesting answer and i think that is what i need. Graph API - Get events by owner/creator
i copy and paste the code, and i change the app-id, the secret and the page, i launch the page but it says "Fatal error: Class 'Facebook' not found in /membri/bestparty/BPARTY4/index.php on line 25"
i included the Facebook php sdk v4 downloaded by github, without composer (yes, i read all the documentation about it, but i don't understand how it works) here is the code
<?php
require_once 'facebook-php-sdk-v4-4.0-dev/autoload.php';
use Facebook\FacebookRequest;
use Facebook\FacebookRequestException;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookServerException;
use Facebook\FacebookSession;
date_default_timezone_set('America/Los_Angeles');
$app_id = '1508703399385376';
$secret = 'c16169730c7dd504f2ba3a88b50e0888';
$page_id = '1482914931991616';
$config = array();
$config['appId'] = $app_id;
$config['secret'] = $secret;
$config['fileUpload'] = false; // optional
$facebook = new Facebook($config);
$fql = 'SELECT
eid,
name,
pic_square,
creator,
start_time,
end_time
FROM event
WHERE eid IN
(SELECT eid
FROM event_member
WHERE uid='.$page_id.'
)
AND end_time >= ' . mktime() . '
ORDER BY start_time ASC
';
$ret_obj = $facebook->api(array(
'method' => 'fql.query',
'query' => $fql,
));
$html = '';
foreach($ret_obj as $key)
{
$facebook_url = 'http://ift.tt/1DUZskN' . $key['eid'];
$start_time = date('M j, Y \a\t g:i A', $key['start_time']);
$end_time = date('M j, Y \a\t g:i A', $key['end_time']);
$html .= '
<div class="event">
<a href="'.$facebook_url.'">
<img src="'.$key['pic_square'].'" />
</a>
<span>
<a href="'.$facebook_url.'">
<h2>'.$key['name'].'</h2>
</a>
<p class="time">'.$start_time.'</p>
<p class="time">'.$end_time.'</p>
</span>
</div>
';
}
echo "$html a";
echo "aaaa";
?>
i want also to know that it works also if i put my profile id, instead of page-id. thank you
Aucun commentaire:
Enregistrer un commentaire