Facebook php api get all past events

Good morning,

I’m searching since weeks to find a solution to get all past events of my user facebook profil. This information will be needed on my website. I read a lot of pagination, but maybe I don’t find the correct help page or until now I do not understand how it will/should work :frowning:

I tried the following code which just lists the next 3 events. But I need all past events :frowning:

	// POSTS GET ALL
	try {
		$posts_request = $fb->get('/me/events?time_filter=past');// as array
	} catch(Facebook\Exceptions\FacebookResponseException $e) {
		// When Graph returns an error
		echo 'Graph returned an error: ' . $e->getMessage();
		exit;
	} catch(Facebook\Exceptions\FacebookSDKException $e) {
		// When validation fails or other local issues
		echo 'Facebook SDK returned an error: ' . $e->getMessage();
		exit;
	}
	
	// Page 1
	$feedEdge = $posts_request->getGraphEdge();
	
	foreach ($feedEdge as $status) {
		var_dump($status->asArray());
	}
	
	// Page 2 (next 5 results)
	$nextFeed = $fb->next($feedEdge);
	foreach ($nextFeed as $status) {
		var_dump($status->asArray());
	}

How can I handle to get all past events from facebook via pagination? What am I doing wrong?

Thank you very much for your help!!! And, mery cristmas by the way :slight_smile:

Best regards!
Stefan

Sponsor our Newsletter | Privacy Policy | Terms of Service