Facebook Graph API - get event generated by page

How can I create all Events Page ?

I tried the following:

https://graph.facebook.com/PAGEID/events

But I do not get any data back.

Can someone help me?

+3
source share
2 answers

I ran into the same problem and also updated the error mentioned by ivan.abragimovich.

I'm not proud of it, but here is what I did while working.

$accessToken = "..."; // your OAuth token
$uid = "..."; // the id of the page you are using
$feed = $this->facebook->api("/$uid/feed", "GET", array('access_token' => $accessToken,
'limit' => 20));

// temp method of retrieving events until the page events bug is fixed.
// @see http://bugs.developers.facebook.com/show_bug.cgi?id=10399
if (array_key_exists('data', $feed) && is_array($feed['data']))
{
    foreach($feed['data'] as $item)
    {
        if ($item['type'] == "link" && strpos($item['link'], "eid=") !== false)
        {
            preg_match('/eid=(\d+)/', $item['link'], $urlMatches);
            if (count($urlMatches) == 2)
            {
                $eventId = $urlMatches[1];
                $event = $this->facebook->api("/$eventId", 'GET', array('access_token' => $accessToken));
                print_r($event);
            }
        }
     }
}
+1
source

Are you sure there are events related to the page? You can check if you can get a feed. Just change the "events" to "feed" in the url.

0
source

Source: https://habr.com/ru/post/1752015/


All Articles