Display Facebook page events on website using PHP

Welcome to the start of our Social Media API Tutorial Series! We will start with this tutorial about how to display Facebook page events on your website using PHP.

In today’s digital age, social media plays a crucial role in connecting businesses with their customers. As a business owner, you understand the importance of keeping your website up-to-date with the latest information about your company, including upcoming events.

However, manually updating your website with events from your Facebook page can be time-consuming and tedious.

In this tutorial, we will explore a solution to this problem by demonstrating how to use the Facebook API and PHP to automatically display your Facebook page events on your website.

With the code provided, you will be able to seamlessly integrate your Facebook events into your website, ensuring that your audience is always up-to-date with the latest happenings at your business.

Say goodbye to manual updates and hello to a streamlined and efficient way of sharing your events with your fans, audience, and customers.

Overview

This code will get the list of events from your Facebook page. It will show data such as event image, name, time, description, etc. from your Facebook fan page without using any Facebook PHP SDK, just the Facebook Graph API!

We will display these event data on a webpage, assuming it is a website made with PHP. We will use a user interface powered by Bootstrap. If you’re not yet familiar with this awesome front-end framework, see our step-by-step Bootstrap tutorial here.

Don’t want to code?

Before we continue coding, if you later realize you do not want to code and need more features, you can use a website plugin called SociableKIT. It is the best no-code tool for the job.

You can easily customize the look and feel of your Facebook page events feed and embed it on your website in 3 minutes. The events feed on your website will update automatically.

Follow this tutorial: Embed Facebook page events on website. You can also use the Facebook group events solution if you use Facebook groups. There’s a free plan that you can use if you don’t need the premium features of SociableKIT.

But if you like coding, continue with our tutorial below!

Final output

We have to know where we are going. If we completed the tutorial below, we will achieve the following output in the video below.

Create the index page

Create index.php file

This page is what will be loaded on the browser. Create an index.php file. Put the following basic HTML code.

<!DOCTYPE html>
<html lang="en">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>Display Facebook page events on website</title>

    <!-- CSS will be here -->

</head>
<body>

    <!-- Container will be here -->

</body>
</html>

CSS code

We’re going to use Bootstrap to make our page look good. We’ll also put some custom CSS. Replace <!– CSS will be here –> with the following code.

<!-- CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link rel="stylesheet" href="custom.css" media="screen">

Create custom.css

These are just some additional customization for our user interface. Create a custom.css file. Put the following code.

.page-header{
    margin:30px 0;
}

.nav{
    margin-bottom:30px;
}

.event_item{
    margin-bottom:50px;
}

Container code

These divs have Bootstrap classes. It will contain our Facebook page events. Replace <!– Container will be here –> with the following code.

<div class="container">
    <div class='col-lg-12'>
        <h1 class='page-header'>Display Facebook page events on website</h1>

        <!-- PHP code will be here -->

    </div>
</div>

PHP code

The code below gets the parameter from the URL about what to display. By default, it is “upcoming” events. The navigation.php file will help the user to select upcoming or past events.

The fb_page_events.php file will contain our request to the Facebook Graph API. Replace <!– PHP code will be here –> with the following code.

<?php
$display = isset($_GET["display"]) ? $_GET["display"] : "upcoming";
include "navigation.php";
include "fb_page_events.php";
?>

Create navigation.php file

This file will show two tabs that will allow our users to select upcoming or past events. Create a navigation.php file and put the following code.

<?php
$upcoming_class_active = $display=="upcoming" ? "active" : "";
$past_class_active = $display=="past" ? "active" : "";

echo "<ul class='nav nav-tabs'>
    <li class='nav-item'>
        <a class='nav-link {$upcoming_class_active}' href='index.php'>Upcoming Events</a>
    </li>
    <li class='nav-item'>
        <a class='nav-link {$past_class_active}' href='index.php?display=past'>Past Events</a>
    </li>
</ul>";
?>

Display Facebook page events

Create fb_page_events.php file

This file will contain the process of building a request to the Facebook Graph API. Create fb_page_events.php file. Put the following code.

<?php
// specify date range will be here

// unix timestamp format will be here

// request parameters will be here

// build the api request will be here

// sort to display upcoming events will be here

// looping through events will be here
?>

Specify date range

The code below identifies the “since” and “until” dates that will be used for the API request. For upcoming events, the “since” date is the date today and the “until” date is two years from today.

For past events, the “since” date is the date from two years ago and the “until” date is the date yesterday.

Replace <!– specify date range will be here –> with the following code.

// specify date range
$year_range = 2;

if($display=="upcoming"){
	// date range for upcoming events
	$since_date = date('Y-m-d');
	$until_date = date('Y-12-31', strtotime('+' . $year_range . ' years'));
}

else{
	// date range for past events
	$since_date = date('Y-01-01', strtotime('-' . $year_range . ' years'));
	$until_date = date('Y-m-d', strtotime('-1 day'));
}

Convert to unix timestamp

Unix timestamp is required by the Facebook Graph API. We will convert the since and until dates using the code below. Replace <!– unix timestamp format will be here –> with the following code.

// unix timestamp format
$since_unix_timestamp = strtotime($since_date);
$until_unix_timestamp = strtotime($until_date);

Specify request parameters

The variables below are needed to complete the parameters needed for the Facebook Graph API request. Replace <!– request parameters will be here –> with the following code.

// request parameters
$api_version = "v11.0";
$fb_page_id = "YOUR_FACEBOOK_PAGE_ID";
$access_token="YOUR_PAGE_ACCESS_TOKEN";
$fields="id,name,description,place,timezone,start_time,cover";

Specify your Facebook page ID and access token

You need to replace YOUR_PAGE_ID and YOUR_PAGE_ACCESS_TOKEN with your own.

To get your Facebook page ID, follow this tutorial. To get your Facebook page access token, follow this tutorial.

We can do this process for you but there will be a service fee of $50. Also, you will need to make us an admin of your Facebook page.

If you want to avail of this service, pay using this link. After the payment, you will receive further instructions from [email protected]

Build the API request

The code below completes the API request link and get the response using file_get_contents() function. We will also decode the response so we can easily retrieve the data. Replace <!– build the api request will be here –> with the following code.

// build the api request
$json_link = "https://graph.facebook.com/{$api_version}/{$fb_page_id}/events/attending/?fields={$fields}&access_token={$access_token}&since={$since_unix_timestamp}&until={$until_unix_timestamp}";
$json = file_get_contents($json_link);
$obj = json_decode($json, true, 512, JSON_BIGINT_AS_STRING);

// for those using PHP version older than 5.4, use this instead:
// $obj = json_decode(preg_replace('/("\w+"):(\d+)/', '\\1:"\\2"', $json), true);

Sort to display upcoming events

Sorting is needed to properly display the upcoming events. The code below will let the upcoming events to be displayed from the date nearest to today up to the farthest date. Replace <!– sort to display upcoming events will be here –> with the following code.

// sort to display upcoming events
if($display=="upcoming"){
	function sortFunction($a,$b){
		if ($a['start_time'] == $b['start_time']) return 0;
		return strtotime($a['start_time']) - strtotime($b['start_time']);
	}
	usort($obj['data'],"sortFunction");
}

Loop through events

The code below will loop through each events returned from the Facebook Graph API. Replace <!– looping through events will be here –> with the following code.

// looping through events
foreach($obj['data'] as $event){
	include "extract_values.php";
	include "display_values.php";
}

Extract and display events data

Create extract_values.php file

In this file, we will extract different types of event data. Create extract_values.php file. Put the following code.

<?php
// start date and time will be here

// basic info will be here

// location will be here
?>

Extract date and time

The code below will let us get the event’s start date and time. Replace <!– start date and time will be here –> with the following code.

// start date and time
$timezone=isset($event['timezone']) ? $event['timezone'] : "America/Los_Angeles";
date_default_timezone_set($timezone);

$start_date = date( 'l, F d, Y', strtotime($event['start_time']));

// in my case, I had to subtract 9 hours to sync the time set in facebook
$start_time = date('g:i a', strtotime($event['start_time']));

Extract basic information

The code below will let us get the event ID, name, description, and thumbnail. Replace <!– basic info will be here –> with the following code.

// basic info
$eid = $event['id'];
$name = $event['name'];
$description = isset($event['description']) ? $event['description'] : "";
$pic_big = isset($event['cover']['source']) ? $event['cover']['source'] : "https://graph.facebook.com/{$api_version}/{$fb_page_id}/picture?type=large";

Extract location

Here we will get the event’s complete address or location. Replace <!– location will be here –> with the following code.

// location
$place_name = isset($event['place']['name']) ? $event['place']['name'] : "";
$city = isset($event['place']['location']['city']) ? $event['place']['location']['city'] : "";
$country = isset($event['place']['location']['country']) ? $event['place']['location']['country'] : "";
$zip = isset($event['place']['location']['zip']) ? $event['place']['location']['zip'] : "";

$location="";

if($place_name){ $location.="{$place_name}"; }
if($city){ $location.= $location ? ", {$city}" : "{$city}"; }
if($country){ $location.= $location ? ", {$country}" : "{$country}"; }
if($zip){ $location.= $location ? ", {$zip}" : "{$zip}"; }

if(empty($location)){
    $location="Location not set.";
}

$complete_event_add="{$location}";

Create display_values.php

The code below will display an event item with data we extracted earlier. Create display_values.php file. Put the following code.

<?php
echo "<div class='row event_item'>
    <div class='col'>
        <img src='{$pic_big}' class='card-img-top' alt='...'>
    </div>
    <div class='col'>
        <h2 class='card-title'>{$name}</h2>
        <p class='card-text'>
        {$start_date} at {$start_time}
        </p>

        <p class='card-text'>
        {$complete_event_add}
        </p>

        <p class='card-text'>
        {$description}
        </p>
        <a href='https://www.facebook.com/events/{$eid}/' target='_blank' class='btn btn-primary'>More info</a>
    </div>
</div>";
?>

Source code or SociableKIT?

You can choose whether to download our source code or use the SociableKIT Facebook page events widget.

FEATURESCodeSociableKIT
Manage events for your Facebook Page and website once
Save time figuring out and coding these features on your website
Display a list of upcoming events
Display event cover photo (profile picture if none)
Display event title
Display event date and time
Display event location
Display event description
Link to actual Facebook page event (opens in new tab)
Responsive layout (great for mobile devices)
No coding required
Works with any website builders like WordPress, Squarespace, or Wix
Customize colors, font, and more
Event details with a map can be shown in a popup
Priority chat and email support
Lifetime support and system updates
No need to worry about Facebook API updates
Use the buttons below. ↓CodeSociableKIT

What’s Next?

Today we have learned how to show your Facebook page events on your website. Did you know that you can also display Facebook photo albums and photos on your website?

Let us go to the next tutorial: How to display Facebook page photo album on website?

[adinserter block=”3″]


Comments

409 responses to “Display Facebook page events on website using PHP”

  1. Will this work for a Facebook BUSINESS Page?

    I’ve struggled with getting a Charity’s Facebook Business Events Calendar to synchronise with Google Calendar on their website.

    It seems Google Calendar likes ‘personal’ Facebook URL’s (found via Facebook>Events>Export) but doesn’t like Facebook’s ‘Business Page’ URL’s Note the slightly longer UID in the following Facebook Business Page for above said example…
    webcal://www.facebook.com/ical/u.php?uid=785985561&key=AQDd5WNUGMUz3HeN

  2. Hmmm are you talking about facebook business accounts? Sorry I haven’t tried it yet since I don’t have one.

    Please note that this script works with facebook pages only, not personal fb account.

    Thanks for your comment. 🙂

  3. Is there a way to show events from multiple facebook users?

  4. Is there a way to post events from multiple users?

  5. @Beat Culture Evolution: It is possible to show events from multiple fan pages but not personal profile accounts. You just have to do another query with your other fan page id specified.

  6. you saved my life! one question.. is there a way to make the events clickable so that users are taken to the actual events when they click on them?

  7. not to sound like a total noob, although i am, is there a way to do this automatically when a new event is created? I’m creating a fan page for a client, and don’t want them to have to constantly update the page. i’ve tried googling it and got nothing.

  8. @heyitshenryy: You just have to wrap each event record with an href to a link to something like https://www.facebook.com/event.php?eid=198530676864407, where 198530676864407 is the event id.

    what do you mean “way to do this automatically when a new event is created”? in this script, once the fan page owner updated his events, it will be reflected automatically to his website.

  9. Can I call the “city” that the event is hosted in? I checked the API documentation and it said to use $values[‘venue’][‘city’], I think…but that’s not working. Thoughts?

  10. @lsm007: You may try to Edit your event and choose “Add street address” option to specify your city and then save changes. And in our script, call $values[‘venue’].

  11. Hi, relative noob im afraid. I’ve got the above working when I go to domain/events.php, works great. However, I know want to call the script from my menu_7.html file. Any ideas?

  12. Placing this script in a .html file won’t work. You have to place this script in a .php file.

  13. Is there a way of displaying an RSVP button along with the event descriptions? Does anyone know?

  14. Thanks Mike, ive put the script in events.php and it works fine when i go to http://www.domain.com/events.php. Prob is I have a events menu item on my site that is menu_7.html. I want to be able to call events.php from that html file.

  15. @Roy: Thanks for your comment but I haven’t tried that, sorry…
    @Rich: Do you mean you want to call http://www.domain.com/events.php via link? as in something like this href link

  16. Hi Mike, thanks for your patience! If you take a look at http://www.g6club.co.uk and click the events menu option you’ll see i’ve got included a hyperlink to http://www.g6club.co.uk/events. What I want to do is skip the link and have the FB events listed directly in that page…

  17. This is exactly what I require but in asp.net. Do you know of a link where I can find an asp.net version of do you have one?

    Thank you

  18. @rich: currently, i see the event menu link is in http://www.g6club.co.uk/index.php?p=1_7_Events, not in http://www.g6club.co.uk/events.php

    i guess you want to include http://www.g6club.co.uk/events.php on your index.php, if you’re familiar, you can try something like include ‘events.php’; at the content part of you index

    @Andrew: Sorry man I only tried this with PHP. But I believe that there’s also a facebook sdk for asp.net and just use the same approach I used here.

  19. Hi Mike. Yeah, theres a link in 1_7 events to take you to events.php. What I want is to get rid of that link… have the results from the php show up directly in 1_7.. I’ll check out include, thanks.

  20. Hi Mike,

    I’ve replaced the app id & secret with my own, however my page events are not appearing. Am i missing a step? Is there a certain way to integrate facebook pages with apps?

  21. Anonymous Avatar
    Anonymous

    Is there a way to make the events display from newest to oldest instead of the other way round?

  22. @Anonymous: maybe you can use the ORDER BY clause in ascending or descending order?

  23. I got an error like “Fatal error: Call to undefined function: date_default_timezone_set() in C:inetpubvhostshttpdocsfacebooktestindex.php on line 19”

  24. Anonymous Avatar
    Anonymous

    HI Mike,

    I really can’t get this to work!

    Any offline paid support?

    David Stump

  25. @SG: I think your PHP version is out of date.

    @David Stump: possible, please use the Request form of this site for your inquiry 🙂

  26. Hi Mike,

    Can the code be edited to also display events(created by others) that you have shared on your FB page

  27. Q2 : How can i add multiple E Id’s

  28. Great script. Thank you. However, I do have a question: How do I exclude past events from the list?

  29. @souzapaul: I think its a yes. as long as it is a public event. you have to do multiple queries. For your Q2, “WHERE eid IN ( SELECT eid FROM event_member WHERE uid = 221167777906963 )”, this part of the script actually allows you to add multiple eids.

    @Romymk: maybe using the LIMIT clause on your sql query?

  30. Ok Mike, I am not a developer so pls.

    Edit the code to Display All events that are shared on Fb page http://www.facebook.com/partygoa
    and also use the limit clause to exclude past events,

    Tell me how much to donate towards your site

    send the code to [email protected]

  31. So I downloaded the zip file uploaded all the files, created a FB app added all the id and secret content but the page is not not producing any content: http://www6.luc.edu/test/cabplan/facebook_events/index.php

    Can you help?

  32. FINALLY! I have been searching for a solid three weeks and could not find anything that worked. THANK YOU SO MUCH FOR THIS. My client will be ecstatic!

  33. Thanks Mike. Actually using ‘AND start_time > now()’ worked for me.

  34. Mike how can you list the events from newest to oldest?

  35. Anonymous Avatar
    Anonymous

    Hey, thanks Code Ninja! It took me much longer than it should have to get this working but it was because despite having a degree in CompSci, I don’t do this type of stuff nor did I know if I was talking to FB correctly. The Examples and tests phps didn’t work for me but the index.php worked great. So after spending time on all of that stuff I figured out some very basic directions:

    1. create the app (like you said), I put in facebook.com/mypage/events in for web page

    2. save the code zip file and extract it, edit the index.php file: you will need the code and secret from the app you created in step 1, AND you will need the UID for the web page. If you don’t know it you can get it from one of the other iframe apps like the like’ button for your website.

    3. in index.php , put in your code and secret where it says, and also change your uid lower in the doc. save.

    4. upload index.php and the folder fb-sdk folder. to some place on your server.

    5. test the page.
    -Mike Quick

  36. Anonymous Avatar
    Anonymous

    PS> is there any way to REVERSE the listing so the newest events are at the top ?

  37. Anonymous Avatar
    Anonymous

    @Chris, check our UID, it may be wrong, that was my issue.. I was using the App ID instead of the page id.

  38. Mike Quick Avatar
    Mike Quick

    @souzapaul, I just tried changing the following in index.php to show the top most recent events, thats all I need:

    $fql = “SELECT name, pic, start_time, end_time, location, description

    FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = 124398140915524 )
    ORDER BY start_time DESC LIMIT 0,10″;
    // ORDER BY start_time asc”;

    -Mike Quick

  39. Mike Quick Avatar
    Mike Quick

    Do you think this could be also used to grab wall posts etc?

  40. Anonymous Avatar
    Anonymous

    Hi Mr Dalisay,

    i am not really into the material, so i dont get it: what are the steps that i need to do to display the events of my fansite to my existing webpage?
    Could you help me?

    Thanks a lot

    Shakermaker

  41. Anonymous Avatar
    Anonymous

    Now i got it, but how can i only show comming events?

  42. Anonymous Avatar
    Anonymous

    Ok I got this to show the events of a Group and personal facebook profile but I cannot get this to produce events of a Page created for the business, how do i configure the php to show a FB page events?

  43. I have my website displaying facebook events from my facebook page thanks to Mike Dalisay!!

    Website:
    http://www.harperslawnornaments.com/index.php?page=504#Sales/Events

    Synced with this page:
    http://www.facebook.com/HarpersStatuary

    Tweaked the script a little, but all credits still go to Mike!

  44. I have the code working but I would like to group events together like facebook such as…
    Today
    This week
    Upcoming
    Ongoing
    How would I change the code to achieve this???

  45. Anonymous Avatar
    Anonymous

    I got this error on your plugin:

    Caught exception: Protocol https not supported or disabled in libcurl

    Any ideas?

  46. Hi! Try url address with http only, without ‘s’ (means secret)

  47. Thank you so much for this. Been digging through the SDK and tutorial all day and I just couldn’t find my way through them.

    I see that there are lots of “thank you” comments. You can be proud !

    Alain, Paris, France.

  48. Does anyone know the code that unknown wrote earlier?
    “I have the code working but I would like to group events together like facebook such as…
    Today
    This week
    Upcoming
    Ongoing
    How would I change the code to achieve this???”

    Thank you all for your help!

  49. Script is working great!

    But how can I show only upcoming events? Now it’s showing all the events.

  50. Yeah, Any clue on how to do what Unknown is saying? Also, is there a way to link to each individual event?

    btw Thanks a lot for this tutorial.

  51. thanks, works fine so far… two things:

    1) how do i translate the date into another language (german, french…)?

    2) how to get street and city for the location? when i put in “venue” instead of “location” it outputs “Array”…

    thanks in advance for any help!

    1. MMM…..is yourproblem solved regarding point 2, because I have the same problem…!!

  52. Thanks for this Mike – It’s very useful.

    @Aditya Nayak asked is there a way to link to each individual event?

    As Mike said in his reply to @heyitshenryy: “You just have to wrap each event record with an href to a link”

    Obviously you will first need to find the eid value of the event to create the link. You get this by simply adding “eid” (without the quotes) to the SELECT statement.

    I used the following to select the next three events – change the LIMIT number to get the number of events you need (NOTE: using end_time > now() ensures that today’s events are included in the list but not past events)

    $fql = “SELECT eid, name, pic, start_time, end_time, location, description
    FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = 123456789012345 ) AND end_time > now()
    ORDER BY start_time asc LIMIT 0,3″;

    I made each event clickable by adding a href link to the //printing the data section around the whole <div class=”event”> element:

    i.e. I changed

    //printing the data
    echo “<div class=’event’>”;

    to

    //printing the data
    echo “<a href=’https://www.facebook.com/events/{$values[‘eid’]}’ title=’Click for more details on the Facebook Event page’><div class=’event’>”;

    and I closed the link by changing the last line of this section from

    echo “</div>”;

    to

    echo “</div></a>”;

    I hope this helps.

    1. Anonymous Avatar
      Anonymous

      This was really helpful, thanks!

  53. Hey

    This code ist really awesome and i just built it into my page and formatted it like i wanted to. But I only get it worked wth your “page id”.

    The Fanpage that I wanted to display is -> http://www.facebook.com/clubsams

    I simply have to copy the Fanpage-ID or not? Or it’s the APP-id? User-id? And put it on the SQL Query?

    like: … IN ( SELECT eid FROM event_member WHERE uid = 318385904895 ) …

  54. @Wella

    You need to change te uid to your fanpages uid. Hereis where you can find it on fb http://reface.me/hacks/your-facebook-uid/ be sure to check the update

    You also need to change the app id & the app secret to the ones you created on https://developers.facebook.com/apps/?action=create

    1. Thanks for your helpful inputs @MX Brothers!

  55. Anonymous Avatar
    Anonymous

    Hi.
    Like Wella, I think this feature is awesome. BUT. I dont have any Appid, as I have made my fan page without developer.
    So what I really have is a url and thats it.

    Is it possible for me to show the events on my website?

    1. If you’re using wordpress, maybe you can use this plugin http://wordpress.org/extend/plugins/facebook-events-widget/, it was based on the script above.

      Other than that, you have to create an app on facebook and follow the steps I gave above..

  56. Anonymous Avatar
    Anonymous

    This is great. Thank you… but…

    Instead of events, I’m getting the below errors. Any ideas?

    “Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /index.php:9) in /fb/src/facebook.php on line 37

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /index.php:9) in /fb/src/facebook.php on line 37″

    1. Hi, please check if you have multiple session declaration…

  57. Hi, i get the events on my webpage but the i want the timeformat to be 24H and the language to be in swedish on the name of the days and months. How do i fixe this?
    Regards
    Pontus

  58. Hello,
    for first – thank you for script, it’s very good job!
    And now I need little help…
    Is it possible import from FB only future events, not past?

    Thanx

    1. You’re welcome @s0uky! Yes, that’s possible, I think our fellow @StreathamMike already answered your question. Please see his post below.

  59. @s0uky,

    To display future and current events only – but not past events – an addition to the $fql SELECT statement is required, as mentioned in my earlier post above.

    If you add “AND end_time > now()” to the end of the SELECT statement this will ensure that past events are not displayed:

    Example:

    $fql = “SELECT eid, name, pic, start_time, end_time, location, description
    FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = 123456789012345 ) AND end_time > now()
    ORDER BY start_time asc LIMIT 0,3″;

    Please Note: as Facebook is based on California time – which was set in this php code at the start – you need to adjust the end_time part of the statement above if you are not in California.

    Example:

    California is GMT-8 hours so as I’m in London I need to add 8 hours to the Facebook end_time to get it to match my local time – so the end time statement becomes:

    AND end_time > now()+(8*60*60)

    Note: Time is calculated in seconds so we have the time difference from California of 8hours x 60minutes x 60 seconds.

    Of course you need to calculate the time difference in your local area for this to be correct for you. Just replace the 8 in the statement with the time difference in hours from California – 9 for CET for example.

    By using the event end_time rather than the event start_time your webpage will display events which are still current. If an event is on from 10am – 4pm it will be displayed on your web page until 4pm – after which time it becomes a past event and will no longer be shown.

    Regards
    Mike

    1. Thank you! I’ll try it.

      I done it with PHP function strtotime().
      It works too, but it’s little bit complicated:

      $start_time = date( ‘g:i a’, $values[‘start_time’] );
      $end_time = date( ‘g:i a’, $values[‘end_time’] );

      $datum_akce = date(‘j-n-Y’, $values[‘start_time’]);
      $aktualni_datum = date(“j-n-Y”);

      if (strtotime($datum_akce) >= strtotime($aktualni_datum)) {
      //printing the data

    2. Hi @StreathamMike, thanks for giving your helpful input!

  60. Alright, galleries and events, pretty easy, how about status’? I fake code pretty well and I’m good at reading it, but my strong suit is design and frontend tech, so bear with me…

    I’ve got my select statement:

    SELECT message FROM stream WHERE source_id=PAGE_ID AND actor_id=PAGE_ID

    I’ll probably build on this once I get this working, but I assume I can add various element from a status, such as image, timestamp, etc. I need to create variables for each of these then output them to the HTML with a little CSS. Anythign I’m missing?

    I’ve been doing some research that says you can’t pull imagery or links from status, but I would think if you have permission and pull the gallery, then you should be able to grab that img ID somehow.. any ideas or tips?

    I’m a newbie to FQL, so any help is appreciated.

    1. I was able to get this simple statement working, I even added a couple parameters to grab the timestamp, name, and a couple other things. What I couldn’t figure out was how to pull over pics. the more I searched through Fb Developer network, the more I kept running into the same script: fbWall.

      Given some time and maybe some help from a better developer than me, I probably could have eventually got it, but this script does exactly what I want it to. I may try and deconstruct the script to see what I still needed to do in order to get it to work.

    2. Hi @Joe, you mean you want to pull also the links and thumbnails of a wall post? How about just using the FB like box with stream enabled? https://developers.facebook.com/docs/reference/plugins/like-box/

    3. Like box and actually fan box have too many limitations first and foremost width and style requirements. fbWall eliminated all that it allows you full control over the feed enabling you to easily customize every part to better fit your site and design needs.

  61. Thanks for this Mike – It’s very useful, good job.
    My question is if you can give me some instructions regarding how to place an fb event attending button on my webpage? I searched for it many places, but nothing useful yet. Thank you in advance.

    1. Hi barney, you’re welcome. I haven’t tried that feature yet and I’m not sure if that’s possible. For now, you can just link your users to your FB events page.

  62. Hi, unfortunately it’s not working for me.
    I don’t understand where I can find the APP_ID_Secret for “Events” – this is a Facebook App – how can I get a secret ID to that public APP?
    The appID for Events is ‘2344061033’ is there more?
    On my developer Page I see the appID and the secret ID all of my fanpage working apps …but those one are useless here I guess 🙁
    I think I missed some important things here 😉 Anybody who can help me?

  63. Hi Mike
    I have found what I have make wrong – I haven’t us the same directory structure to the facebook library….shame on me 🙂
    No it’s works very good. Great that u share that knwoledge! Thanks a lot
    loMB

    1. I’m glad it helped. 🙂

  64. Anonymous Avatar
    Anonymous

    I want to use this on a site but I am having a hard time understanding APP Ids. I don’t own the Facebook account or web site I am using. Would I need to log in to Facebook under my clients name, create a ID with that? Then this ID is associated with that user? Or do I create an account for development purposes with Facebook and then I can develop for other sites with one ID. Just don’t understand how myself, the website and Facebook all interact.

    1. Hi Anonymous! Yes you have to own a Facebook account. You can create a new account for your clients or just use your own FB account (I actually use my own FB account, haha!).

      I recommend creating a new ID for each of your app. For example you have created an app ID for http://yoursite.com, you have to generate another id for http://clientsite.com

      This link will get you started when you want to develop FB apps for websites https://developers.facebook.com/docs/guides/web/ or https://developers.facebook.com/

  65. Anonymous Avatar
    Anonymous

    This is a great code sample. Many thanks for posting. I have been trying to create an equivalent snippet using JavaScript. Unfortunately the ‘select’ statement seems to blow up.

    As a test I ran
    “SELECT name, venue, location, start_time FROM event WHERE eid = xxx”. This works.

    However ‘SELECT name, pic, start_time, end_time, location, description FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = yyy ) ORDER BY start_time asc” does not seem to work

    Here is the code snippet. Any ideas

    FB.api(‘/event’,function(response)
    {

    var fql_query = ‘SELECT name, pic, start_time, end_time, location, description FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = xxx ) ORDER BY start_time asc’;

    alert(fql_query);

    var query = FB.Data.query(fql_query);

    query.wait(function(rows) {
    //
    alert(‘query results’);
    });

    });

  66. How would I add a login to facebook and then get the events of that user (not a specific events page)

  67. Thank for a job well done.
    Pls i want to be able to get information from Facebook with the keywords on Nigeria, Events, Wedding, Make Up Artists, Mobile Network, Photographers etc. This is not just on a particular fan/friend. Kindly assist

  68. I’m sorry. I really want to use this for my website, but I have no idea how to even get started using these type of things. is their a video or can you walk me thru the steps of putting this where it needs to go> I absolutley am clueless when it comes to this stuff.

  69. Anonymous Avatar
    Anonymous

    How i can use it in a wordpress blog?
    Can you help me please!? Thx a lot

  70. Excited to say I’ve been able to take your code and actually implement it, so, before I ask a question–THANK YOU!

    Here’s the page that will have the Facebook Events feed: http://alicroft.com/empresscal/
    It should be pulling data from: http://www.facebook.com/TheEmpressRva?sk=events

    Not sure why, but I’m getting a display of old events. Note that the first four events on my site’s feed are outdated, and if you visit the Facebook page it is supposed to be pulling from, you’ll see there is a new event (Best of Richmond Thank You at The Empress) that it isn’t listed on my custom feed. Any help would be greatly appreciated!

    1. Ali,

      In order to display only current and future events you need to add “AND end_time > now()” to the end of the SELECT statement:

      For details please see my post in reply to @s0uky on Jan 29 above.

      StreathamMike

  71. Luxuskern Avatar
    Luxuskern

    How can i translate the Month and the Day in German ? i find no answer 🙁 please can you help me?

  72. Dear Mike,

    Thanks for your tutorial:

    It works great, but just have a question concerning startdate/starttime and enddate/endtime.

    I add an event which start at 07 april at 21:30 and ends at 08 april 01:00. But at the site it shows only:” on Sunday, April 08, 2012 – 5:30 am to 10:00 am “

    see: http://jackkunkels.nl/Display-Facebook-Events-To-Your-Website-with-PHP-and-FQL/

    facebook: http://www.facebook.com/pages/jackkunkels/162678887146825?sk=events

    How can I change this in index.php

    Thanks in advance
    Arthur

    1. Arthur,

      Remember that Facebook uses California time.
      Please see my Reply to @s0uky on Jan 29 above.

      It should help you.

      StreathamMike

    2. Hee Jeroen,

      Heb je al een oplossing ?

      Groet
      Arthur

    3. Hee Mike,

      I did some alterations with:

      $fql = “SELECT eid, name, pic, start_time, end_time, location, description FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = 162678887146825 ) AND end_time > now()+(9*60*60) ORDER BY start_time asc LIMIT 0,3”;

      But still the output is California time….

      Please can you help Jeroen en me…!!

      Thanks
      Arthur

    4. Anonymous Avatar
      Anonymous

      hoi Arthur,
      oplossing is bizar simpel. In het script van Mike tijdzone op America/Los_Angeles laten staan en je evrnts worden goed getoond.
      Wel rekenen als je een eindtijd exact op het moent van je lijst wil.
      groet Jeroen

  73. Hello Mike,
    thanks for your great script. Works!
    but I seem to have the same problem as Arthur, even if i put my timezone in your script.
    [date_default_timezone_set(‘Europe/Amsterdam’)] http://www.triestos.nl/index.php

    The scripts adds 9 hours??

    What am I doing wrong? Thanks. Jeroen

  74. This comment has been removed by the author.

  75. Hee Mike,

    Jeroen gave me the right answer by set the timezone on America/Los_Angeles. Thanks to Jeroen.

    Just another question: Is it possible to add also the Venue with the google-map for the location ?

    thanks
    Arthur

  76. Anonymous Avatar
    Anonymous

    this is awesome!…. is there an updated version that will work with new facebook?

  77. Excellent script and very well documented.

    My question is that no matter what I do I can not fetch the last three events, I only seem to get the current and future events.

  78. Anonymous Avatar
    Anonymous

    How to make it FQL from events change to share links?

    I changed your coding on the FQL, but the image not work
    Result after changed your coding there
    http://www.miracle-mart.com/FB2

    Since I can post the coding on your blog…
    So I upload the index.php to my blog for your reference what is wrong on it.

    http://explorerhome.dyndns.org/photoevent/index.zip

    Thank you of your time and help and share this coding.

    Best Regards,
    Jimmy Chan
    http://explorerhome.dyndns.org/blog

  79. Thx for this code!
    How can I add an option to translate the dates? I’ve seen that two people asked the same thing but no answer yet at least on this page 😉 Isn’t something as easy as a param ? Thx in advance!

  80. Jonathan Avatar
    Jonathan

    This is great and works well, but I’d like to list the profile image of those attending each event.
    Any idea of how I could add that to the code so when each event lists, it shows perhaps a random 5 people who have marked the event as ‘attending’?

  81. Hi, I have managed to create an app on facebook and fill in all the boxes in the widget.

    But nothing is showing up on my webpage. – Should i wait for you to get the codes up on your index.php file?

    Thanks

  82. Heee Mike, The +9 hours doesn’t work anymore, how come…>

    Still has the code:

    $fql = “SELECT eid, name, pic, start_time, end_time, location, description FROM event WHERE eid IN ( SELECT eid FROM event_member WHERE uid = 162678887146825 ) AND end_time > now()+(9*60*60) ORDER BY start_time asc LIMIT 0,3”;

    and date_default_timezone_set(‘America/Los_Angeles’);

    He doesn’t raise the time with 9 hours…!!!

    greetz
    Arthur

  83. oke I already has the answer…

    date_default_timezone_set(‘America/Los_Angeles’); is working, so I changed it by date_default_timezone_set(‘Europe/Amsterdam’);

    sorry for bothering you

    Arthur

    1. No, no, thanks for sharing your fixes Arthur, I really appreciate it! 🙂

  84. Hi, Just asking once more, why the events has not showed up on my page?

    I created an app on facebook, and entered all the information into the widget.

    Is there anything more to do from here?

  85. Hello Mike,

    Im trying to instal you app in heroku but i cant see the events. can you help me?

    The link to my app is: http://electric-leaf-6369.herokuapp.com/

    Tks

  86. On July 5th, Facebook changed something with the timezones and now I am getting December 31, 1969 for all event dates. Is anyone experiencing this?

    I even get the wrong dates using the sample files downloaded above, put directly on my server, unedited (aside from app id, etc). However, the live demo seems to be fine. How?

    Thanks.

    1. A week ago i was running the app ok, but since two days ago all dates show Dec 31 1969!

  87. I’m having the December 31, 1969 issue as well. Has anyone come up with a fix?

    1. Anonymous Avatar
      Anonymous

      got the same problem! please some help here!

  88. Anonymous Avatar
    Anonymous

    I only say Mike Dalisay You are The BEST BEST BEST. Thank you

  89. Dear Mike, thanks a lot for this tutorial. I have one question. Is it also possible to let people react to an event from your website. I want the option that people can give up their RSVP from my website, so they don’t have to go to Facebook.

    Kind regards, dennis

  90. I have another question… Can I display a message if there are no upcoming events?

    1. Yes, that would be excellent. How to do that?

  91. Hi Mike,
    I have a question for you.
    Instead of Facebook Pages, Can we create and export events from a Facebook Application?
    I had created an app in Facebook, and I want to create/export events from facebook to my website and also from my website to facebook app.
    Is this possible?
    Please Help!

  92. Thanks for the script! This is a huge time saver! Unfortunately, I am having trouble with calling the venue. I have added venue to the SELECT query. When I call it by using echo $value[‘venue’]; it returns “array”. When I call the city with echo $value[‘city’]; nothing is returned. HOWEVER, other queries work perfect (name, description, start_time, and location).

    Not sure if this is from how I am creating the event? I am tagging a business in the “where” field when I create the event. The address shows in the event, but it will not let me get the city and state.

    I’m new to all of this; sorry if this is a stupid question. 🙁

    Any suggestions?

  93. Hello Mike,

    I really neeed your help man!

    In your Photo Album post, I am getting following error,

    Please help me to solve it…

    Fatal error: Uncaught Exception: 102: Session key invalid or no longer valid thrown in /Applications/XAMPP/xamppfiles/htdocs/facebook/fb-sdk/src/facebook.php on line 515

    [email protected] is my email ID. Please some one help me to solve it.

  94. Hello guys, I think the reason for most of the problems we are having here is because of some inconsistencies in Facebook APIs, in which we don’t have any control of.

    You can always be updated by visiting their documentation pages. Just like here, please take a look at their “Events Timezone Migration Note” https://developers.facebook.com/docs/reference/fql/event/

    Thanks!

  95. Hi Mike! Thanks for this awesome tutorial. Really helped me out. I used this on the following website: http://www.zero-sanity.nl/

    I got one problem though. As you can see the past event doesn’t remove itself from the list. Do you have any idea what the cause of this is?

    Thanks in advance!

    1. Hi Tom,

      I see you got it working on your website. Mind sharing your code? I’m using it for a Dutch website and the date and time is just messed up. The date says Wednesday, December 31, 1969
      10:00 – 4:00 pm and I’ve tried any fixes for it posted on here. As you’re Dutch too, did you edit anything specifically?

  96. Hi Mike,

    first of all thank you for this great tutorial. I used to one on this website: http://www.zero-sanity.nl

    I got one problem though. The past event is still showing. Do you have any idea what the cause of this is and how I can solve this?

    Thanks in advance.

    Tom

    1. Hi Tom, you’re welcome! did you add start_time >= now() in your query?

      1. Hi Mike, thanks for your response. It fixed it 🙂

  97. For the Problem with 31 December …. copy the following code to your Index.php
    and change your date_default_timezone_set…

    $start_date = $values[‘start_time’];
    $timestamp = strtotime($start_date);
    $start_date = date(“d.m.Y”, $timestamp);

    $start_time = $values[‘start_time’];
    $timestamp = strtotime($start_time);
    $start_time = date(“H:i”, $timestamp);

    1. Thanks Michael! Or to be shorter, you can do something like:

      $start_date = date(“d.m.Y”, strtotime($values[‘start_time’));
      $start_time = date(“H:i”, strtotime($values[‘start_time’]));

      1. Norris Avatar
        Norris

        Type in ninjazhai’s $start_date line. It should be:

        $start_date = date(“d.m.Y”, strtotime($values[‘start_time’]));

  98. hi mike – great script but there is a solution for the timezone
    problem? the note on the fb developerpage does not bring me more, im not
    a programmer ;-( for example: im setup following data (see attachment)
    the result is – on Thursday, January 01, 1970 – 1:33 am to 1:33 am –
    see on pocuca.com/fb
    many many thanks in advance

    1. Hi Nele, thanks! Would you give your link to FB event page so we can better examine the problem..

      1. sure – i hope you can help me
        http://www.facebook.com/events/512407225465047
        thanks

        1. I mean your website demo link also…

        2. Hmm.. did you have your end time set? else I think you have to show us your code, you can paste it in http://pastebin.com/ and link it here, thanks…

          1. hi mike, yes see attachment and the code http://pastebin.com/szHkbtgb
            thanks in advance

          2. we can’t see you code even if we log in, try https://gist.github.com/

      2. hi mike, it works with the new code and input from michael
        thanks at all

        1. I’m glad it works for you now Nele 😀

  99. Sebastian Avatar
    Sebastian

    Hi. It’s working great 🙂

    How to set this to display only 3 events and in the description only 10-15 words?

    1. Hi Sebastian, you can append limit 0,3 to the query to limit results to 3 events.

      Maybe you can limit the description to 15 words by doing $descriptionArr = explode(” “, $description); and then loop through it to get the first 15 items (words) to compose the 15-word description.

  100. Stephan Avatar
    Stephan

    All works, but above the events i get the following code. What does this mean?

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /kunden/webseiten/stephan/contao/facebook/index.php:47) in/kunden/webseiten/stephan/contao/facebook/fb-sdk/src/facebook.php on line 49

    1. Try adding ob_start(); at the very beginning of you script (after your php tag), let us know if it works…

      1. Hello Mike,
        thank you for this perfect solution. I search now for a while to find this post. And it works after a half hour. Great. In which document i have to add the snippet. I tried to add this in index.php and facebook.php, but the error message already display. http://welcome-media.de/labor/facebook-event-to-website/
        Greetz Andi

        1. you already added ob_start();?

          1. Hello Mike,
            I run into similar problems.
            http://www.schuetzenhaus-lichtenau.de/facebook-event-to-website/index.php
            But additionally I dont get the events listet.

          2. hi @facebook-100003180940426 , did you try my solution..

          3. If you mean the “ob_start();” at the beginning,yes I tried it out

  101. $53577695 Avatar
    $53577695

    Hello Mike

    Thank you for your examples!

    I recently used your example for load photos from Facebook using my app id and secret, and it works on any page (even if mine or not) i proved.

    Now, i proved this code on two pages: COAN-Dummy-Page and AwenMasajes (my own page), but this code works only on your page, using my app id and secret.
    I don’t understand what is access token, what is the difference between that and my app id and secret.

    Do you have any idea of what i have to do?

    Thank you very much, again.

    (sorry for my poor english)

    1. Hi pepe, thanks for dropping by! Access token is used when you want to pull photos from a Facebook profile, but this script can be used only for Facebook fan pages.

      1. $53577695 Avatar
        $53577695

        That’s what i did. But your code olny works on the fanpage COAN-Dummy-Page and doesn’t work on my fanpage AwenMasajes. I don’t know what is the difference betweeen them. What i have to do with my fanpage? The code is the same, only change the fanpage’s id.

      2. $53577695 Avatar
        $53577695

        I’m sorry for wasting your time. I dont know what i did, but it works now. Thank you for all.

  102. simonerama Avatar
    simonerama

    Hi Mike,
    Only one thing, I suggest to convert the date in PHP as follows:

    $starttime = ”.$values[‘start_time’].”;
    $st = new DateTime($starttime, new DateTimeZone(‘PST’));
    $st -> setTimezone(new DateTimeZone(‘CET’));

    Echo:
    format(‘d-m-Y H:i:s’); ?>

    To avoid the PHP error “A non well formed numeric value encountered”.

    Btw amazing tutorial.

    1. Thanks for this tip man! 😀

  103. Spilab Avatar
    Spilab

    Hi

    i have created the app as you described and coiped the app id and secret to the index.php. I filled in my uid and tried it on my web with no success. i don´t get any errors, the web is just all white and blank.

    My webhost runs php “Version: 5.2.10-2ubuntu6.10” and i copied all the other files in same structure you described.
    Do i have to prepare the app with permissions, other details to be able to read from my events_menber db?
    Regards
    Uffe

    1. Hi @bd343b4cf33a15d1ae5fd5a30e6d4a72 , would you give us your testing link?

      1. Spilab Avatar
        Spilab

        Hi

        Here is the link, http://www.garvaren-noje.se/index2.php

        our facebook page is here, https://www.facebook.com/garvarennoje
        thanks in advance
        Regards Uffe

      2. Spilab Avatar
        Spilab

        Hi again
        It seems like that my webbrowser not will run the code under the body tag, i viewed the source after i loaded the site and it only showed the css and the body tag and nothing more.

  104. croco2511 Avatar
    croco2511

    What do I have to change in the code so only the past events show up (https://www.facebook.com/pages/COAN-Dummy-Page/221167777906963?sk=events&key=past). I played with different start_time() settings, but so far no luck.

  105. and how to display the events that are happen now in a latitude and longitude place?

    1. I think that’s not possible @facebook-100001348566137..

  106. Very helpful though I’ve been spending hours trying to figure out how to use the venue array to show the address info for each event (city, street, state). Any advice?

    1. Hi @facebook-31702369, the table says you can only query the ‘location’ and ‘venue’ https://developers.facebook.com/docs/reference/fql/event

      1. Cristiano Andrade Avatar
        Cristiano Andrade

        Thanks for your code @ninjazhai !
        When you query ‘venue’, you get an ARRAY with: id, street, city,state, zip, country, latitude, and longitude

        What can I do to show each one?

        1. You’re welcome Cristiano Andrade! Hmmm can you show me the array? How about something like:

          $id = $your_array[‘venue’][‘id’];
          $street = $your_array[‘venue’][‘street’];
          $city = $your_array[‘venue’][‘city’];

          …and so on..

          1. Cristiano Andrade Avatar
            Cristiano Andrade

            Yes, that is it. But before, you need to include “venue” on your DB SELECT. Thanks!

  107. Jean-Yves Theriault Avatar
    Jean-Yves Theriault

    sorry i’m having a hard time here, all I have is a blank page, see http://www.katacombes.com/facebook , any help would be much appreciate, thanks!

    1. Hi @Jean, did you have your app ID and secret keys?

      1. Jean-Yves Theriault Avatar
        Jean-Yves Theriault

        yes but what i found so far is the page is not a fan page, it’s a business page, can i convert it or can i get a fan page, basically i need the url to be like, https://www.facebook.com/pages/Blacky/289551724435535?ref=hl , right now it’s https://www.facebook.com/coopkatacombes , ok the Blacky page is also one of mine and that one I can get the events to display as well as the photos, but not for the coopkatacombes, is there a way I can convert or request a second url. I have to tell you that facebook is very confusing, 😉

        1. Jean-Yves Theriault Avatar
          Jean-Yves Theriault

          Ok I fit the problem, was so simple, in the FB setting we had age restriction “over 18” selected, now it work with “anyone 13+” problem solve…

          1. Thanks for sharing your solution here @facebook-810932247!

      2. Jean-Yves Theriault Avatar
        Jean-Yves Theriault

        and yes I did have the app ID and secret keys, just see it work with my blacky account, so far what i have found is because the blacky does not have a username for that particular page but the coopkatacombes and the voivod do, is there a way around that

  108. click_wrrrrr Avatar
    click_wrrrrr

    Interesting Error…
    this error occurs right out of the box on set up.
    Everything else is fine, but that is an annoying error.

    Undefined variable: prev_button in pull-facebook-datapull_fb.class.php on line 151

    1. Hi @twitter-621235264, I think it has something to do with your server setup. You have to explicitly define every variable in your code.

  109. MayJuly Hlwan MoeThu Avatar
    MayJuly Hlwan MoeThu

    Hello,

    what wrong on me?
    //////
    Warning: session_start() [function.session-start]: Cannot send session cookie – headers already sent by (output started at /home/asiaterm/public_html/index.php:8) in /home/asiaterm/public_html/fbsdk/src/facebook.php on line 49

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/asiaterm/public_html/index.php:8) in /home/asiaterm/public_html/fbsdk/src/facebook.php on line 49

    This event list is synchronized with this mypage |

    Fatal error: Uncaught Exception: 190: Invalid OAuth access token signature.
    thrown in /home/asiaterm/public_html/fbsdk/src/base_facebook.php on line 1271
    /////

    error on my site , how to fix them ? pls help me

  110. Mike,

    I wanted to know if you knew of a way to display a url in the event description on Facebook as a link in the event description on the webpage? Any thoughts?

    Thanks in advance.
    Also great tutorial!

  111. pigsound Avatar
    pigsound

    hi mike,
    i’ve been trying to make your code run on my website without for several hours without any success. i set up your files, changed the IDs to mine, but when the page loads, it only shows the html part of your script.
    can you tell by this little information where i could have made a mistake?
    thanks in advance, pixie

  112. pigsound Avatar
    pigsound

    hi mike,
    still trying to solve the problems i’m stuck in:
    i uploaded your scripts to another server (no test server!) and it still doesn’t work. but now i at least get some error codes:

    with “facebook-event-to website” i get:

    Fatal error: Uncaught CurlException: 28: connect() timed out! thrown in /cluster/www/mydomain.com/facebook-event-to-website/fb-sdk/src/base_facebook.php on line 994

    with “pull-facebook-data/show_events.php” i get:
    Fatal error: Uncaught CurlException: 28: connect() timed out! thrown in /cluster/www/mydomain.com/pull-facebook-data/fb-sdk/src/base_facebook.php on line 886

    what am i doing wrong?

  113. I keep getting this error message, even when changing nothing on your example index.php:

    Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at /home/twofr0/public_html/bands/theunicornz.com/new/events.php:47) in/home/twofr0/public_html/bands/theunicornz.com/new/fb-sdk/src/facebook.php on line 49

    I am stuck at this point and could use any help in figuring it out.

    The test page is:http://theunicornz.com/new/events.php

  114. Question: My site is not pulling the correct dates and times. It is showing Wednesday, December 31, 1969 at 4:33 pm — Do you have any experience with why that might happen? Is that a default/fallback date? Can I share our test link directly with you for assistance? Thanks

    1. Same here, I have this exact same problem. The fix N0fear posted doesn’t work. Would greatly appreciate a fix because this seems like a great script.

      Link: http://www.cafepensiondepegel.nl/agenda/

      1. Hello @KB @nickbetting, it looks like you guys were able to fix it. Let me know if you found other issues, I’ll reply faster this time.

  115. Jens Bergander Avatar
    Jens Bergander

    I have problems with the date.

    Whatever I do, I will get a wrong day, wrong month and wrong year.
    I.m from Germany Berlin.

    What should I do?
    I tried: date_default_timezone_set(‘Europe/Berlin’);

    🙁

  116. Jens Bergander Avatar
    Jens Bergander

    Hi,

    i have some problems with the date.

    Whatever I do, I get incorrect date

    wrong day, wrong year.

    i try to change my timezone
    date_default_timezone_set(‘Europe/Berlin’);

    and what i do, i get a wrong date.

    what can i do?

  117. *Luis* Avatar
    *Luis*

    Hi Mike,

    just discovered this great script and have it up and running on the following testpage:

    http://mitcas.de/fbtest/

    The problem i see is that the description of the event doesnt get formatted the way it is on the facebook fan page.

    For example here: https://www.facebook.com/events/529085623825726/

    you get this:

    —————————-
    “Einlass : 19 Uhr
    Beginn : 20 Uhr
    VVK: http://www.gibson-club.de/de/tickets

    Erst einmal ist da diese Stimme… großartig und schillernd wie er auf der Stimmpalette tanzt. Von krä…..”
    —————————-

    But on the above testpage with your unmodified script you get all text in one line…:

    —————————-
    “Einlass : 19 Uhr Beginn : 20 Uhr VVK: http://www.gibson-club.de/de/tickets Erst einmal ist da diese Stimme… großartig und schillernd wie er auf der Stimmpalette tanzt. Von kräfti…”
    —————————-

    How can we fix that? Seems like your script is not reading the breaks from the event-description.

    THANK YOU SO MUCH FOR YOUR HELP! 🙂

    1. I found a solution to this issue, just change:

      echo “{$description}”;

      to

      echo nl2br(“{$description}”);

      This did the job for me!

  118. THANK YOU so much for all your work on this and other tutorials. Is there any way to also have the text for the events hyperlinked to the actual event pages??? Thanks again!

    1. You’re welcome @Nick, you can use the approach I used here to create that link, see the events section http://www.codeofaninja.com/2012/05/display-facebook-data-to-your-website.html

  119. This is awesome! Please, please can someone help me get it in ASP? :-/

    1. Thanks @disqus_wjUg6gIb0J, sorry no one reports any ASP version of this… but that should be easy with the help of FB ASP SDK.

  120. Is this available in ASP anywhere?
    Thanks

  121. Hi is there a solution to work around the age / alcohol restriction?

  122. Hi is there a way to work around the Age Restrictions and Alcohol Restrictions on some Facebook pages?

    1. Hi @disqus_ZiFT1ivRHL, I never encountered any age/alcohol restrictions, what’s the situation there?

      1. Hi 🙂 I was working on a page that shows events of a city, So i loaded from night clubs that have page restrictions 21+ But error 100 pops up. When u are using graph the error is (http://graph.facebook.com/ ) Try http://graph.facebook.com/bacardiclassiccocktails its has no events but an age restriction. so see the error

        1. I see, unfortunately, if the graph does not give the results, this script can’t do the job. It will only work for the publicly available data. I hope in the future, the Facebook graph/SDK will be able to automatically detect if a user is allowed to view restricted contents.

  123. For anyone having problems with the date showing up like a default date (1969 or 1970), try this:

    Inside the App dashboard click App Settings > Advanced. Set the ‘Events Timezone’ to disabled.
    It is enabled by default. If enabled timestamps are ISO-8601. This does not work with this PHP code.

    1. Thanks for this tip @05ef695336acdeee2be9961fc0018d61!

    2. Raimonds Blūms Avatar
      Raimonds Blūms

      that option is no longer there. even in this demo it shows the date of December 31, 1969

  124. Hendrik Veeman Avatar
    Hendrik Veeman

    I am no PHP or JS programmer and am trying to get the website I uphold for the owners up to date.

    The owners of the cafe put the events on their Fb account, and i am now trying to implement it into their site http://www.cafetsjoch.nl

    I haven’t got much luck so far getting it integrated. Something is somewhere getting it wrong but I don’t know where and why.

    the test page is: http://cafetsjoch.nl/fbevent.html

    My first attempt was http://cafetsjoch/test.html but it was blank in whatever i tried.

    As you can see at the site i use i-frames and ajax-files
    Hopefully anyone can help me.

    1. Hi @hendrikveeman! It seems like you’re using just HTML for this, you have to use PHP.

      1. Hendrik Veeman Avatar
        Hendrik Veeman

        It is a mix of HTML and php
        FB-SDK is also implemented

  125. Radek Cichocki Avatar
    Radek Cichocki

    Two things I don’t get.

    1) The UID here is hard coded. When I change it to mine or to one of my friends’, I get zero results. Why?

    2) How come you don’t need to be logged in first for it to work?

    1. Hi @radekcichocki!
      1. UID can be changed to facebook fan pages only.
      2. You won’t need to login because the fb fan page data/pictures were publicly available.

      1. Radek Cichocki Avatar
        Radek Cichocki

        Thanks for your reply!

        That explains it. I am wondering… If I wanted to get events that were posted to an open, public group (not fanpage):

        1) Would I still not need to log in?
        2) How would I need to change the FQL query to do that? (I’m new to Facebook apps)

  126. Bas Koole Avatar
    Bas Koole

    Hi Mike, thanks for the great script. I’m a programming novice, but got this running the way i wanted to pretty quickly. I’ve got one thing i couldnt figure out: I would like to use setlocale() to show the weekday in dutch. Could you elaborate how i can implement this in your script? Thanks in advance, i owe you a beer.

  127. treps_92boy Avatar
    treps_92boy

    Hi Mike,
    First, thanks for this amazing tutorial. I’ve just got a tiny little problem. Today’s event doesn’t appears. At 00:00 the same day as the event it disappears from the site. Any idea how I can fix it?
    Thanks in advance.

  128. troppic_burrito236 Avatar
    troppic_burrito236

    Hi
    I successully got this example working with my own fan page however the time and dates are different from those of the actually events on my fanpage. I changed the time zone in the code but this doesn’t fix this. Any suggestions?

  129. Dan Cooprider Avatar
    Dan Cooprider

    Mike, Im new to web design…. really I am a 3D VFX artist trying to pay the bills with web-design. Sadly I am not much of a code person yet. Now, one thing i am getting is that people want to embed or stream their facebook events page to their website. I have created an App ID and App Secret… now what am I doing wrong with your code in this example. I am using Adobe Muse as my web building tool, any help would be appreciated.

    1. Good for you @dancooprider, but what exactly is the issue? Do you have a link where we can see your work and maybe get some idea about the error.. Thanks..

  130. Raimonds Blūms Avatar
    Raimonds Blūms

    Something has changed recently, plugin now outputes the date of 1970, january 1

    1. Hi @raimondsblms, I see, I’ll look into it and try to update this week. Thanks for the report!

  131. Hi Mike, thank you for useful script and tutorial. We used it for band website here – http://goo.gl/BYOp5c . But now I can’t manage problem with event’s dates – date is showing “January 01, 1970” – same is in your demo page now: http://demo.codeofaninja.com/show/98 Any tips how to handle this? Thank you.

    1. I saw you fixed it on your side, could you share the fix with me please?

    2. Hi @mirekmolin, I apologize for the late reply, I see that my code has some problems now due to facebook changes, it looks like you fixed it on your side, can you share us how? Thanks!

      1. Yes, it looks like Facebook changed date format. I tried strtotime() function and it works. @n0fear posts cleaner code above.

        1. Yup @mirekmolin, I updated the code yesterday with reference to @n0fear’s fix! 🙂

  132. If anyone elese got the 01.01.1970 Problem. Changing

    $start_date = date( ‘l, F d, Y’, $values[‘start_time’] );

    to

    $start_date = date( ‘l, F d, Y’, strtotime($values[‘start_time’]));

    did the trick for me. Thanks for this nice script!

    1. Thanks for this working tip @n0fear!

  133. n0fear Avatar
    n0fear

    Hi together, i am a real beginner in coding, is it possible to link the Title to the facebook event als an URL? So if someon clicks on the title he gets new page opend with the event? How would i do that?

  134. joomsch Avatar
    joomsch

    I think i do have a problem with my app. I always get “Restricted access” at my page. Do I have to set some settings in my App to get access ?

  135. Sergio Avatar
    Sergio

    Hello and THANK you this this amazing work! 🙂 I still have a problem… I did the proper replacement —-$start_date = date(‘l, F d, Y ‘, strtotime($values[‘start_time ‘]));—- and I have the data showing as 31 December 1969! 🙁 What is wrong? Anyone can Help? Thanks

  136. Sergio Avatar
    Sergio

    And by the…is there any way to change the language from English to any other? Thanks one more time.

  137. ninjazhai Avatar
    ninjazhai

    How about writing your event in your own language (other than english)?

  138. ninjazhai Avatar
    ninjazhai

    are you sure you set up the start date/time properly?

    1. i follow all your instructions properly…still i am getting no output

      1. Hello @disqus_TvXTPgMCK7, would you send a link to your test URL? Also, please make sure JSON and allow_url_fopen PHP extensions are enabled in your server.

  139. ninjazhai Avatar
    ninjazhai

    how long does your fb page exist? is it public? or has any age restriction?

  140. Bartek Talar Avatar
    Bartek Talar

    Hi there.
    I have a question. how to replace that instead of a thumbnail display cover?
    greet.

    1. ninjazhai Avatar
      ninjazhai

      Hey @bartektalar , good suggestion, please try to look at the events table, there should be a ‘cover’ photo field or something that you can try to access!

      1. Bartek Talar Avatar
        Bartek Talar

        Hi!

        The problem has been resolved.
        just under $ FQL = “SELECT pic_cover add and link the image looks
        src = {$ values ​​[‘pic_cover’] [‘source’]}

        fb good job! 🙂

        1. ninjazhai Avatar
          ninjazhai

          Hey @bartektalar , thanks for sharing your solution!

  141. Hi, any ideas how to get only PAST EVENTS too?
    I tried this fql query, but it doesn’t work:

    start_time < now()

    Upcomming events works fine.
    Thanks

  142. Hi, it is very great tutorial but I faced with problem that I can’t solve, I tried to launch my page with my app id and secret and with my page id but I got this: http://vivaretro.hol.es/event/ just everithing goes blank

    here is the code:

    Display Facebook Events to You Website

    ‘331817830310323’,

    ‘secret’ => ‘4b90b95abc7c3e3a0c68f4f583982911’,

    ‘cookie’ => true

    ));

    /*

    *-Query the events

    *

    *-We will select:

    * -name, start_time, end_time, location, description

    * -but there are other data that you can get on the event table

    * -https://developers.facebook.com/docs/reference/fql/event/

    *

    *-As you will notice, we have TWO select statements here because

    *-We can’t just do “WHERE creator = 132064480282039”.

    *-Only eid is indexable in the event table

    * -So we have to retrieve list of events by eids

    * -And this was achieved by selecting all eid from

    * event_member table where the uid is the id of your fanpage.

    *

    *-Yes, you fanpage automatically becomes an event_member once it creates an event

    *-start_time >= now() is used to show upcoming events only

    */

    $fql = “SELECT

    name, pic, start_time, end_time, location, description

    FROM

    event

    WHERE

    eid IN ( SELECT eid FROM event_member WHERE uid = 221167777906963 )

    AND

    start_time >= now()

    ORDER BY

    start_time desc”;

    $param = array(

    ‘method’ => ‘fql.query’,

    ‘query’ => $fql,

    ‘callback’ => ”

    );

    $fqlResult = $facebook->api($param);

    //looping through retrieved data

    foreach( $fqlResult as $keys => $values ){

    /*

    * see here http://php.net/manual/en/function.date.php

    * for the date format I used.

    * The pattern string I used ‘l, F d, Y g:i a’

    * will output something like this: July 30, 2015 6:30 pm

    */

    /*

    * getting start date,

    * ‘l, F d, Y’ pattern string will give us

    * something like: Thursday, July 30, 2015

    */

    $start_date = date( ‘l, F d, Y’, $values[‘start_time’] );

    /*

    * getting ‘start’ and ‘end’ time

    * ‘g:i a’ will give us something

    * like 6:30 pm

    */

    $start_time = date( ‘g:i a’, $values[‘start_time’] );

    //printing the data

    echo “”;

    echo “”;

    echo “”;

    echo “”;

    echo “”;

    echo “{$values[‘name’]}”;

    /*

    * -the date is displaying correctly, but the time? uh, sometimes it is late by an hour.

    * -it might also depend on what country you are in

    * -the best solution i can give is to include the date only and not the time

    * -you should put the time of your event in the description.

    */

    echo “{$start_date} at {$start_time}”;

    echo “{$values[‘location’]}”;

    echo “{$values[‘description’]}”;

    echo “”;

    echo “”;

    echo “”;

    }

    ?>

    I tested to comment some rows and it seems like problem appears when php comes to this row:
    $fqlResult = $facebook->api($param);

    Do you have ideas why it is so?

    1. ninjazhai Avatar
      ninjazhai

      Hey @Paul, there are some change in Facebook’s system right now, I will update his post asap. I think that is what’s causing the problem. Please connect with us via FB or twitter for the updates, thanks!

  143. Nicolas Leitgeb Avatar
    Nicolas Leitgeb

    Hey Mike, i hope this is still working in general and you can help me. I wanted to integrate this into my homepage but it doesnt work, so i tried it standalone but i only get a blank site with the header… whats wrong there, i used ur code here and did every step very carefully…

    1. ninjazhai Avatar
      ninjazhai

      Hello @nicolasleitgeb, I think there are some changes in Facebook’s system right now. I will have to update this article asap. Keep up with the updates by connecting with us via facebook or twitter, thanks!

  144. Andrew Clark Avatar
    Andrew Clark

    This no longer works with the new facebook php sdk. Any chance of the article being updated?

    1. ninjazhai Avatar
      ninjazhai

      Hello @disqus_l8035fmf9x, thanks for bringing this to my attention, I’m going to update this article asap!

      1. Andrew Clark Avatar
        Andrew Clark

        I found this very helpful: https://www.webniraj.com/2014/05/01/facebook-api-php-sdk-updated-to-v4-0-0/

        With that I could build a page to get auth tokens for the pages I manage. After that put together a script to pull a page’s events out of Facebook: http://www.hdoc.com.au/events.php

        It runs a bit slower than I’d like as it makes two queries to the graph api (one to pull the ids of the page’s events, a second to pull the details of those ids). I could cache the data returned I guess but there’s probably more headaches in that too.

        1. ninjazhai Avatar
          ninjazhai

          Thanks for the extra help @disqus_l8035fmf9x, I appreciate it! I’m gonna look into it and try to make it faster or optimized.

  145. ninjazhai Avatar
    ninjazhai

    Hello everyone! I updated the source code and tutorial again (September 3, 2014), I did not use the FB PHP SDK this time. Please let me know if there’s any issue, we’ll look into it, thanks!

    1. Hi! Love your work! I was refreshing this page multiple times/day for a new guide….However, there is an issue with the demo page

      1. ninjazhai Avatar
        ninjazhai

        Hi there @lason! Glad to know you love our work! But what issue do you see in the demo page? Please tell us any error message you see, thanks!

        1. @ninjazhai it seems to be working now!

  146. Paul Mintskovsky Avatar
    Paul Mintskovsky

    Hi mike, your tutorials are awesome! Thank you for update for this tutorial =)
    I don’t know why anything isn’t working for me.. Its just go blank http://migrash.org/test.php
    here is a printscreen part of the code:

    1. ninjazhai Avatar
      ninjazhai

      You’re welcome @paulmintskovsky, thanks for using our code here! Regarding your issue, your code looks fine, it’s hard to find out what’s the error if it has no error message… would you try to paste your fb page id?

  147. Is this outdated? It doesn’t seem to be working

    1. followed every step carefully.. doesn’t seem to work for me as well. everything is blank with no error.

      i think it has to do with a setting on facebook dev site?

      1. It’s weird though because his live demo is still working.. I’ve added more functionality to my site and now this is the last thing to do.. He uses FQL in this, isn’t this depreciated unless your facebook application was created months ago?

        1. ninjazhai Avatar
          ninjazhai

          Hello @disqus_Jqj3qiit9f and @Alan, are you using PHP 5.4+? Would you put error_reporting(E_ALL); at the beginning of your PHP file so that we can see any error message, and tell us here. Thanks!

          1. Philippe Avatar
            Philippe

            I’m using PHP version 5.3.29
            and have the following error message:

            file_get_contents(https://graph.faceb….AYB6EeQ): failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in /home/dice…e/event2.php on line 57 Notice: Use of undefined constant JSON_BIGINT_AS_STRING – assumed ‘JSON_BIGINT_AS_STRING’ in /hom…ource/event2.php on line 59 Warning: json_decode() expects at most 3 parameters, 4 given in /home/dicetat…k-feed-source/event2.php on line 59

            thanks for your help

          2. ninjazhai Avatar
            ninjazhai

            Would you guys try to use:

            $obj = json_decode(preg_replace(‘/(“w+”):(d+)/’, ‘\1:”\2″‘, $json), true);

            instead of:

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

          3. Philippe Avatar
            Philippe

            Only 1 error now.
            failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request
            in /ho..ent2.php on line 55

            line 55 has: $json = file_get_contents($json_link);

          4. ninjazhai Avatar
            ninjazhai

            @disqus_Jqj3qiit9f, are you on localhost or an on-line server?

          5. ninjazhai Avatar
            ninjazhai

            The value of your $fql looks weird, why does it have a lot of ‘+’ characters: q=SELECT%0A++++++++++++eid%2…

          6. Philippe Avatar
            Philippe

            no idea 🙁 is there anything else I can try to get it to work?

          7. ninjazhai Avatar
            ninjazhai

            I tried your fb page id, it works at my end, see this live demo http://demo.codeofaninja.com/tutorials/display-fb-events-on-website/phil-example.php

            How about trying it on another web server? or give me an ftp access so I can check out your complete code, send me a message on our fb page…

          8. Hi. Thank you for the tutorial!
            Was this issue resolved? I am getting the same error (online).
            Thanks–

            Warning: file_get_contents(https://graph.facebook.com/ …. [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 400 Bad Request in … on line 32

            (Using $obj = json_decode(preg_replace(‘/(“w+”):(d+)/’, ‘\1:”\2″‘, $json), true);)

          9. @disqus_67ugo85UD5, yes that issue can be solved easily, you maybe have a wrong graph API url or access token, or your server is rejected by Facebook due to high amount of request (problem with shared hosting). Would you give us your test URL?

          10. I am testing on a local host

          11. ninjazhai Avatar
            ninjazhai

            @Alan, I haven’t actually tried it in localhost, I don’t know if it will work there..

          12. Also this is probably a stupid question but I’ve never used php before – how do I check which version I’m using? I’ve only recently installed it so I’m assuming I have the latest version

          13. Sorry for the spam I’m running PHP 5.6.1

          14. Hi I’ve attached an image

    2. Hi.. I implement this code and something is wrong…
      http://pierogi.odsniezka.pl to the right sidebar.. I print a COUNT from JSON

      I use 2 codes of exploding json to php> 5.4 and <5.4

      And not working..

  148. Hey guys,
    is it possible to display events of two or more fb sites in one list? (e.g. for a Band agency or however to call it in english 😀 )

  149. Nicolas Leitgeb Avatar
    Nicolas Leitgeb

    Hey Guys,
    is it possible to display events of more than one site in one table/list e.g. for band agencies who want to display upcoming events of bands they support…

  150. ninjazhai Avatar
    ninjazhai

    Hey @Arek, are you sure your JSON extension is installed in your server? You can find out using phpinfo();

  151. ninjazhai Avatar
    ninjazhai

    Hello @nicolasleitgeb, yes, it is possible to display events from multiple Facebook pages to one webpage. 😀

    1. Nicolas Leitgeb Avatar
      Nicolas Leitgeb

      Yeah 😀 that was not actually what i meant.I mena events from several pages in one list chronologically.

      1. ninjazhai Avatar
        ninjazhai

        Oh, yes it is possible, you just have to retrieve all the events first, save them to database, and then retrieve the events chronologically from the database. 🙂

  152. This works for page events but not events based on a profile. This is the error: Warning: json_decode() expects at most 2 parameters, 4 given. Do you know how to make this work with profiles.

  153. bob holling Avatar
    bob holling

    Hi there…question: do you know if your method works with age-restricted content? A friend has a liqueur business and would like to post his tasting events from FB to his WordPress website. All attempts thus far have failed due to FB’s policies on age-restricted content, so wondering if your solution would solve for that. Thanks!

    1. ninjazhai Avatar
      ninjazhai

      Hello @bobholling, in this case, I believe Facebook would allow us to pull publicly available data only. No any kind of restriction such as the age-restricted content.

      But I haven’t really tried any workaround on that, maybe it’s possible now but I don’t know how to do that yet.

  154. Hi ninjazhai,

    i bought pro version and i used it locally with success but when i tried to upload to remote hosting( Altervista) the events loading fails and i can’t see anything on page other than links and template.

    http://www.colorseventi.altervista.it/eventi.php

    Can you help me?

    1. ninjazhai Avatar
      ninjazhai

      Michele, thanks for purchasing the code! I will support you personally via email, please send me an email to [email protected]

      Update: It looks like you solved it now, glad it worked for you!

  155. Hi Ninjazhai,

    Is there any way to display the Facebook events on Google Sites website ?

    Thank you for your tutorial.

    1. ninjazhai Avatar
      ninjazhai

      Hello @Herve, yes there is a way to display it on Google sites! You’re welcome.

  156. SergioJavierre Avatar
    SergioJavierre

    Hi! I’m using this tutorial but I found an error in my query. In my case, I’m quering a page with a dot in the page ID. Also I used the facebook page ID but I can’t get the results. Could you help me? Thanks!

    This is my query: https://graph.facebook.com/el.veintiuno.1/events/?fields=id,name,description,location,venue,timezone,start_time,cover&access_token=MY-TOKEN&since=1356998400&until=1483228800

    1. ninjazhai Avatar
      ninjazhai

      Hello @Sergio, you have to replace MY-TOKEN with your own access token… change it in your URL above…

  157. Chadas Avatar
    Chadas

    Hi there, I`ve downloaded your src, everything’ s alright, but I get a blank page. Please help me out. thx

  158. WhiteGrass Avatar
    WhiteGrass

    Can someone tell me how can I add multiple Page IDs to fetch events from? I don’t want just one, I want from more than one. Thank you!

    1. ninjazhai Avatar
      ninjazhai

      Hello @whitegrass, you can do it with comma separated FB page IDs like what I used in this sample link:

      https://graph.facebook.com/events?ids=221167777906963,9189674485&fields=id,name,description,location,venue,timezone,start_time,cover&access_token=YOUR-TOKEN&since=1357023600&until=1483254000

      The disadvantage is you have to implement multiple for loop for each FB page ID because the result is not a linear JSON stream…

  159. Hi!
    Could you tell me how to display only specific upcoming event?
    Thank you very much!

    1. ninjazhai Avatar
      ninjazhai

      Hello @disqus_2eQpOXlOMe, you’re welcome! You can do it by specifying the event ID on the graph API URL…

      1. Hi! Only the $json_link should be modified? Could you please share a example, how this string should look like in order to meet graph API needs. Thank you!

  160. ninjazhai Avatar
    ninjazhai

    @Chadas, it looks like the JSON extension on your server was not enabled or broken. I replied to you on Facebook how to solve this.

  161. Thank you so much, was looking forever for a solution to this

    1. ninjazhai Avatar
      ninjazhai

      Hello @monolithdoes, I’m glad this solution was helpful to you! Thanks for visiting our site!

  162. Piratesfan Avatar
    Piratesfan

    What about sort by date? It says 9. april before 1. april.

    Perfect plugin

    1. Hello @disqus_yTOGsUjuT1, unfortunately, Facebook still doesn’t provide us with a sorting feature even to this date. See my reply to Vanessa Keeton above as alternative solution.

  163. Laurent Loiseau Avatar
    Laurent Loiseau

    Hi

    Awesome tutorial. Almost everything works well for me. I just had to change the variable $fields. Facebook says fields “location” and “venue” are deprecated. I replaced it by the field “place” 🙂 Then, you can display the following fields :

    “place”: {
    “name”: “LA SOUTE”,
    “location”: {
    “city”: “Chambu00e9ry”,
    “country”: “France”,
    “latitude”: 45.568758364409,
    “longitude”: 5.916880680781,
    “street”: “Citu00e9 des arts jardin du Verney”,
    “zip”: “73000”
    },
    “id”: “175714291355”

    Thanks a lot for sharing your experience ! (and sorry for my poor english 😉 )

    1. Hello @laurentloiseau, thanks for reporting this, I’m updating the code above and sending the source code update to people.

  164. menathor Avatar
    menathor

    Awesome work Mike- great to see the new version using the Graph API!

    One thing though- I noticed the same timezone problems as the fql version. You can see it on the demo of the pro version- just check out the date and time displayed on your page for some of Ed Sheeran’s events and compare them to the date / time of the actual Facebook event. You’ll notice that they’re different because you’re in a different timezone.

    I corrected this in the old version by setting the date_default_timezone_set() value for each individual event to the timezone value of that event. Could you add this fix to the new code as well?

    1. Hello @menathor, sorry for the late reply. You’re correct, for others who are reading, please add the following code inside the ‘for’ loop (see step 11 above)

      date_default_timezone_set($obj['data'][$x]['timezone']);

  165. Nicolas Leitgeb Avatar
    Nicolas Leitgeb

    Hey, everything works fine,i am just still modding to use it without bootstrap.
    But is there a way to make it nicer responsive?

    1. Hello @nicolasleitgeb, you can do it with the help of CSS media queries. You can check out our tutorial https://www.codeofaninja.com/2013/01/responsive-web-design-code.html

  166. Vanessa Keeton Avatar
    Vanessa Keeton

    How do I change the order of the events? Currently the most future date is showing first in the list. I need them to be in event date order.

    –Update: I did a little research and it seems there isn’t a what to change the order of items in the graph API, so I sort of combined your older FQL version of this with the newer version. It works fine now, since I can change the order from the query. I also think that this wouldn’t work if I had not already created the app before the Graph API was released and I am not sure if FB will just break this sometime soon. But for now, at least it works.

    If you know of a way to do it with the graph API, I’d still love to know it.

    Thanks for sharing your code! I was happy to buy it the second time around because it is very useful for my clients. 🙂

    1. Hello Vanessa Keeton, unfortunately, Facebook API does not give us the ability to sort the order of events, but I made a workaround for it. Use the following before the ‘for loop’ code:


      function sortFunction($a,$b){

      if ($a['start_time'] == $b['start_time']) return 0;

      return strtotime($a['start_time']) - strtotime($b['start_time']);

      }

      usort($obj['data'],"sortFunction");

      The only disadvantage is that, it will only sort the currently loaded JSON content.

      Thanks for the kind words and sorry for the late reply…

      1. Vanessa Keeton Avatar
        Vanessa Keeton

        Thanks for the reply! I’ll give this a try next time I am making an update to the site or if I use this on another. 🙂 Thanks again for sharing your ninja skills.

  167. Thomas Bloom Avatar
    Thomas Bloom

    First of all thanks for the excellent tutorial, I already successfully used this code on 1 website. I am running into an issue with the second website I am working on.

    The issue that I am having is that I cannot display the most recent events from my facebook page but can only show events from 2011?

    I have echo’d the since_date and since_date variables to ensure that the dates are correct but no matter what I do I cant get events to show, only events that happened a long time ago in 2011. Is there a limit to the number of events the application can pull?

    I have a feeling this is a facebook issue and not an issue with the code but any insight would be appreciated.

    1. Hello @disqus_0d0j4DwshJ, thanks for the kind words! I’m glad it worked on your website. About your concern, this is a new report, what we usually encounter is the events from 2012 does not show. Would you link us to your Facebook page and test URL so we can investigate more?

  168. You can take a look here https://github.com/newbacknew/owloo.com. This is a base of scripts from http://www.owloo.com for get data from Facebook via the “ADS” Dashboard, also have to retrive analytics data from Twitter and Instagram.

    With the base script you can get trends, interests, behavior, demographic, ages, gender qty of every country, city, stage, fanpage from facebook.
    The base of all script are in the WSERVICE folder of the backups folders.

    1. Nice script, thanks for sharing @disqus_CQlZaSB8st, are you the one who made this?

  169. Thanks for the tutorial. I wasn’t able to make the code work until I found that I had to remove brackets in step 8 Json link. Thought this might help others in the same situation. Cheers

    1. Hello @disqus_7Q6D0fzAdH, you’re welcome! The code works with brackets, I’ve tried it in different servers. Would you tell us the error your faced when you tried to put the brackets?

      1. I put them back and it works nice finally, I wasn’t aware of the “{$var}” syntax so I might solved another error while changing it to ‘.$var.’ sorry for wasting your time.

        I’m currently looking for a way to show events created by users but it seems I need a user access token or something, could you point me some places to look at please ? I’d like to make an upcoming concert list from multiple promoters (pages and users), it works fine with pages as you can see here : http://www.bisento.fr/

        1. @disqus_7Q6D0fzAdH, your were able to display events from multiple fb pages, that’s cool! But were you able to add an ‘infinite scroll’ feature? About events created by users, yes I think user access token is needed for everything created by users. I haven’t tried to play around with that so I can’t really give a good reference for you..

  170. Hi..Do you also have any demo script where in pasting the facebook event url will give me all the details of that event.

    1. Hello @Abhishek, I’ll build that demo, thanks for the idea!

  171. Daniel Mort Avatar
    Daniel Mort

    Is the pro scripts code still working with facebook to date? Thanks

    1. Hello @daniel_mort, yes they are still working! You can check out the live demo links provided above. 🙂

      1. Daniel Mort Avatar
        Daniel Mort

        Just wanted to say thank you. Just purchased the script pro pack today not too long ago and modified it a bit to make it a dark theme and it’s working great. It took a little bit figuring out how to style each individual element, but I have a basic idea now. In any case, it saved me A LOT of time! I read something about having to get an access token from Facebook? Well I just changed the pageid and it seems seems to work. What will i need the access token for? And lastly, is there a place to change pageid and access token globally, or do I have to change it on each page? Thank you!!!!!!!

        1. Hello @daniel_mort, thanks for purchasing the source codes! We are glad you found it useful and saved you a lot of time.

          About your questions, yes it will work with the current access token, but it is more recommended to use your own access token. See the step 7 on how to obtain your own access token. One advantage of having your own access token is, you won’t be affected just in case the current access token had problems.

          About global page ID and access token, currently, you have to change it by page, but we’ll change it in future updates. For now, you can use PHP includes or sessions so it can function like a global variable.

      2. Daniel Mort Avatar
        Daniel Mort

        Okay, one last question. How do I sort the events from most recent to farthest away? Upcoming events and all events in particular. Past event’s tab seems to be in the correct order, but there’s only 5 showing of 50+ past events. no page 2 or anything.

  172. @daniel_mort, please see section 5.1, it answers the question about ordering the events…

  173. Hans Blaettler Avatar
    Hans Blaettler

    Hi, great script! But one question: my sitemap generator keeps adding pages because of each upcoming month, although $year_range = 1; and it won’t quit generating because of all the years ahead 😉 Please advise what to do so I can update my sitemap? #thanx

  174. Hello @hansblaettler, would you give us your test URL so we can investigate more about this issue? Also, please send your code to my email [email protected] so we can study what’s wrong

  175. Hi there

    Is it possible to add a “Sign Up” button, so the sign up can be done via the website?

    If so I would like to purchase the pro-version 🙂

    /Jacob

  176. Hello @disqus_JlaTMSb053, what exactly are you trying to do? Is it the “login with facebook” button? If so, that feature is not covered by our source code above.

  177. Valeria Avatar
    Valeria

    Hello,

    We are looking for a way to retrieve the list of event attendees from Facebook. Ideally, if the attendee has an account on our site (given that he signed up with Facebook), he should be recognized as a user, so we can use this information for the loyalty program. We are using WordPress.

    I’ve been searching for a while already, and none of the available solutions gives the option of retrieving/importing the attendee list. I’m not familiar with the Facebook API and it’s hard for me to imagine what would it take. Could you advise on that?

    Also, would you be interested in developing a plugin like that (or rather a customization to an existing plugin that imports events)?

    Thank you.

    1. Hello @disqus_JsLmgyf2ZS, what you want to do is possible. Facebook graph API allows you to retrieve the list of attendees of an event. You can match users in your database with that information. That way, you will be able to detect if a user attends an event.

      Unfortunately for now, I am working on several projects already and can’t take on another one. Thanks for considering me to develop this kind of plugin.

      1. Valeria Avatar
        Valeria

        Thank you for the answer and for the detailed tutorial.

        1. You’re welcome @disqus_JsLmgyf2ZS!

  178. Joel Boucher Avatar
    Joel Boucher

    Hey there, I was just wondering how I would go about having the time and dates of the events appear in another language, for example french?

    1. Hello @disqus_vUxqyfiQ0I, unfortunately Facebook API does not return data in another language. But you can try using

      setlocale(LC_TIME, ‘fr_FR.utf8′,’fra’);

      See: http://php.net/manual/en/function.strftime.php#118581

  179. Ori V Agmon Avatar
    Ori V Agmon

    Hello thank you SO MUCH for this helpful information.
    _
    THERE is a way to pick the specific events from my facebook acount, that I want to be shown on this tool?

    1. Hello @orivagmon, yes there is a way to do it, but it must be under a Facebook page, not a personal account.

  180. suthemeny Avatar
    suthemeny

    Hi! I really like this solution to display events on my website!

    I’m a little bit confused… I’m wondering how to define to display only the next 3 events… I made a loop, but if I don’t have 3 upcoming events, only 1 or 2 it displays blank rows with the page profile picture as event image, what I don’t need…

    My loop is:
    for($x=0; $x<3; $x++){
    // here comes the table…
    }

    What I want is to display only the row(s) that have real content.

    Thank you!

  181. Hello @suthemeny, thanks for the kind words! About your concern, would you give us your test URL and FB page URL so we can test it at our end? Which events do you wish to show?

    1. suthemeny Avatar
      suthemeny

      Thank you for the quick reply.

      My test page is:
      http://zajtaiorsolya.hu/fb/upcoming.php?fb_page_id=208040919235322

      Fb page is:
      https://facebook.com/Gesarol/

      The fb page has now only one event… and if I set that it should only show the next 3 and there is less than 3 events… it breaks…

      1. @suthemeny, we are unable to replicate your issue, our demo with your page shows only 1 event:

        https://www.codeofaninja.com/demos/display-facebook-events-basic/upcoming.php?fb_page_id=208040919235322

        Please send us your code via email [email protected], we’ll take a look.

        1. suthemeny Avatar
          suthemeny

          Hi! I figured out what was missing… now it works.. the solution was:

          for($x=0; $x<$event_count && $x<3; $x++){

          }

          I forgot the "and" operator from the line.. now if I have more than 3 events, it only shows the next 3 and if I have less than 3 it shows only 1 or 2 without a fake blank event row… 🙂

          Thank you for helping,

    2. suthemeny Avatar
      suthemeny

      Hi! Do you know what the problem is? Thanks!

  182. Nicolas Avatar
    Nicolas

    Wow … I was looking to finally do that and It took me few hours to understand facebook doc. Now with your website, it took me 10 min. Thank ! It was very easy to do it and to understand !

    1. You’re welcome @Nicolas, thanks for telling us your story and your kind words, glad to help you and save you time!

  183. dorisweldonkaz Avatar
    dorisweldonkaz

    I just wanted to thank you again for both the code and for your help! My husband says we owe you a beer! Brilliant work and a very kind person. Thanks again.

    1. You’re welcome @dorisweldonkaz! Thanks for downloading the code and your kind words. Glad to help you with your awesome website. Regards to your husband too. 🙂

  184. Marouan Avatar
    Marouan

    Hello, thnks for your Doc, its very Interessant and i have used. So, my question is, i want to get all FB Events with Tags or Cateroy . But i dont have any information im internet finded.
    For example :
    Event Name : ABCD
    Start Time : 10.07.2016
    End Time : 13.07.2017
    Interessed : 120 Person
    Category : Musik
    Tags : musik, sport, halloWorld,..
    etc…

    Plz, have you any Idee ? Thnk you very much

    1. Hello @disqus_izibY1wBsd , thanks for the kind words! About the feature you described, our script cannot do that. But we’ll try to work on it in the future.

      1. Marouan Avatar
        Marouan

        Thnk your for your Response, So Yes, your Script cannot do that. I will be very happy to have a positive response.. have a good day 🙂

  185. Greetings! Thanks for this script. It has been very helpful. I have set it up on a website for a music venue. It displays upcoming events and I am using the re-order script to display them in order from the most imminent. It seems that it is starting with events that are two weeks away instead of displaying the events closest to today’s date. I am using the script in two places on the site. On the Home page and on the Events page. Any thoughts on this? I assume it has something to do with the json data grab.
    Here is the website and its corresponding facebook page:
    http://www.lamascobarandgrill.com
    http://www.lamascobarandgrill.com/events
    https://www.facebook.com/lamascobarandgrill

    1. Hello @BigTonyTheNinja , glad our script helped you! About the issue, you can try to change the $year_range value to 5 or 10, then use the ‘re-order’ script in section 17.0 above.

  186. Akeem Sca Avatar
    Akeem Sca

    Hi Mike, thanks for the amazing tutorial! I’m just wondering how long the access_token (described in 9.0) will last?! Is it hours, days, months or do these have unlimited lifetime?

    1. Hello @akeemsca , I’ve been using mine since 2013. It still works as of today.

      1. Akeem Sca Avatar
        Akeem Sca

        thank you very much for your quick answer!! i’ll test it in production 🙂

  187. Daniel Fernandes Avatar
    Daniel Fernandes

    hi! Thank you so much for this amazing tutorial!!!
    But how can I change the language? Like its “Wednesday, March 27, 2013 at 12:00 pm” and i want that on portuguese :/

    1. You’re welcome @disqus_bUPEOU48gR ! About your question, please try the following and let us know of the result. http://php.net/manual/en/function.strftime.php

      1. Daniel Fernandes Avatar
        Daniel Fernandes

        Thank you for the reply!! It works!

        1. Glad it worked @disqus_bUPEOU48gR! Please share our site to one of your friends if you have time. 🙂

  188. It’s not working with Facebook latest APP v 2.7. Any solution ?

    1. Hello @disqus_QTHEjnjOfU, I updated our code tutorial and demos with v2.7, and it still works. We are unable to replicate your error. Tell the any error message you see on your work. Thanks.

  189. I’m not able to get my facebook page id

    1. Hello @Mike, you can use your Facebook page username instead.

  190. Dustin Rogers Avatar
    Dustin Rogers

    Hey there, I could use some help with this… The code works great, and Ive used it on sites before, but the problem I am having now is that the code doesnt work with this one Facebook page I use. It works for all other Facebook pages I try except this one. Is there a setting within Facebook pages that prevents this code from working?

    1. Hello @disqus_fy32CWCXA4 , would you post the link of your Facebook page? Page must be publicly available, please check if your page has something like age restriction. If there is, try to remove it and try again.

  191. Dominik Waitzer Avatar
    Dominik Waitzer

    It works fine but it just show me events which starts from 24th of Mar. 2017 – I’ve tried everything I think, but it’s not possible to show me all events which starts from tomorrow. Help?

    1. Hello @dominikwaitzer , would you send us your FB page URL and test link? We’ll try to replicate the issue and fix it. Thanks!

  192. multigamerr85 Avatar
    multigamerr85

    Can you make updated article, because this code doesn’t work anymore. When i put myt $json_link to address bar on web browser it returns empty string.

    1. Hello @multigamerr85, our live demo links are working. Our tutorial are updated based on our live demo links. What exactly is the $json_link that you put in the address bar? Do you see any error message?

  193. Hello @Marcus, it looks like you’re trying to retrieve events from a personal Facebook account. Unfortunately, our script above only works with public Facebook pages.

    1. Ah, ok, thanks!

  194. Hey, great tut, extremely invaluable. I only have one issue, tried from scratch a couple of times but to no avail.. I only get 1 record/event showing even though the data has 8 upcoming events.

    I’ve been testing it here http://test.alacakseyler.com/facebookeventtest/test1.php

    Any pointers would be greatly appreciated!

    1. Hello @Luke, thanks for the kind words!

      We are unable to replicate the issue, your Facebook page works well with our script as see in our live demo: https://www.codeofaninja.com/demos/display-facebook-events-level-1/all.php?fb_page_id=izmiryoga

      You can try to add the ‘limit’ parameter in the URL of $json_link, for example:

      &limit=100

  195. BonjourAlex Avatar
    BonjourAlex

    Excellent work ! Thank you very much ! =D

    1. Thanks for the kind words and you’re welcome @BonjourAlex!

  196. Hello, does this code work on fb closed groups?

    1. Hi @fadial , no. It works only for public Facebook pages.

  197. Jonas Niedermair Avatar
    Jonas Niedermair

    The code works fine on localhost but when i upload the files on my server it doesnt work…
    $event count is always 0

    1. Hello @jonasniedermair , make sure JSON extension and allow_url_fopen is enabled on your web server.

      1. Jonas Niedermair Avatar
        Jonas Niedermair

        JSON extension is enabled but allow_url_fopen is only the local value enabled and the master value is disabled .. is this correct or have I to enable both ?

          1. Jonas Niedermair Avatar
            Jonas Niedermair

            Thank you for the reply!! It works!:)

          2. You’re welcome @jonasniedermair ! Glad it works for you now.

            Please subscribe for future updates: https://www.codeofaninja.com/subscribe/

  198. Jonas Niedermair Avatar
    Jonas Niedermair

    Hello @ninjazhai the code is great! But do you have an idea how I can save the description of a facebook event in my MySQL database if the text of the description includes special chars like ❤ , • …
    I have already tried to convert the string with html_specialchars but it doesn’t work..

    Thanks for your help !:)

    1. Hello @jonasniedermair , did you try to insert the data without using a function like html_specialchars()?

      1. Jonas Niedermair Avatar
        Jonas Niedermair

        Yes I have already tried to insert the event description in my database without html_specialchars()… but it doesn’t work

        the error occures with the description of this event: https://www.facebook.com/events/203941600087594/

          1. Jonas Niedermair Avatar
            Jonas Niedermair

            Your links were very helpful!
            I have added this line into my code:

            $description = mysql_real_escape_string($description);

            Thank you very much for your help !:)

          2. You’re welcome @jonasniedermair !

            Please subscribe https://www.codeofaninja.com/subscribe

            Or share our site to one of your friends if you have time. 🙂

  199. Ramon Strapatsen Avatar
    Ramon Strapatsen

    Hi,

    It works, but it didn’t show all the events. Some events aren’t show on the website.
    All the events are public and events hosted with more admin are loading also..

    I also checked it with the demo’s (changed the page_id in the link) it didn’t load.

    What could be the problem?

    1. Hi @ramonstrapatsen , would you send me the Facebook page you’re trying to use? I’ll try to replicate the issue and provide a fix.

      1. Ramon Strapatsen Avatar
        Ramon Strapatsen

        Thanks for the quickly response, sorry i was 2 busy 2 answer till now..
        Don’t know if i can put the full url here, so i do it this way.
        put “onderbroeknijmegen” at the end f the fb url.

        Thanks! This weekend is the event that doesn’t load. So i hope you find it.
        before that date, because every past event loads.

        1. I’m unable to replicate the issue, it works using our script with your Facebook page. Here’s a live demo:

          https://www.codeofaninja.com/demos/display-facebook-events-level-3/index.php?fb_page_id=onderbroeknijmegen&show=upcoming

  200. Laxmikanta Nayak Avatar
    Laxmikanta Nayak

    can you create a plugin which will search events based on location ?

    1. Hi @laxmikanta_nayak , I don’t think that’s possible with Facebook API.

  201. Michelle Currier Avatar
    Michelle Currier

    Is anyone gettting an error on the this line:
    $json = file_get_contents($json_link);
    It worked for me a few weeks ago last time I checked my site but now I have this error.
    My site is djnicerack.com/events.php

    1. Hi @michellecurrier , try to update your API version to /v2.8/. If you want to prevent situations like this, try using a website plugin like this: https://www.displaysocialmedia.com/embed-show-display-facebook-events-on-website/

      1. Michelle Currier Avatar
        Michelle Currier

        totally updated to 2.8 already doesn’t change anything. my console error says that the ; on the end of the line need to be a , instead but i know thats the wrong syntax and it kills the php

        i would love to have my events working on my site since im a dj and it used to like a few weeks ago.

        1. @michellecurrier, we are unable to replicate the issue. But I’m glad you made it work now, would you share how you solved it?

      2. Michelle Currier Avatar
        Michelle Currier

        i updated the api still no luck 🙁

        1. @michellecurrier , did you try to update your access token?

  202. Chrétien Wetemans Avatar
    Chrétien Wetemans

    when i use facebook id: 292612564117649 something goes wrong, any idea

    1. Hi @chrtienwetemans, your Facebook page has age or country restriction. Please remove the restrictions. Our script above will work.

  203. Hi @janvanweert, thanks for reaching out. Unfortunately, Facebook has turned off the events API and all we can do for now is wait for them to make it work again.

  204. Hi @disqus_p49iSQMFJj, thanks for the kind words! Unfortunately, Facebook still have the events API turned off. Once they turned it on, that’s the time we can make our next move.

  205. Hi @mdikici, unfortunately, even with the latest API version 3.0, the events API is still turned off. All we can do for now is wait for Facebook to turn it on again.

  206. HI @itsamikkie, unfortunately, the Facebook events API is still turned off at the moment so it won’t work.

  207. Hi @sang tran, unfortunately, the Facebook events API is still not working at the moment. Any request we make will not work.

  208. Thanks for the kind words @disqus_yOq0aCGSR8! I believe the “limit” parameter still works. Did you try it?

    If not, you can control to show only two events using a counter in the for loop.

  209. Hi @Samuel, yes it still works. I just tried the demo link above and it still shows the events.

  210. Hi @margandavor, the demos are working here on my end. Would you try again now?

  211. This is working great, but is it possible to include co-hosted events?

    1. Hi Stein, thanks for letting us know it works for you! Yes, if an event was co-hosted by your Facebook page, it will show up on the feed.

      1. I also experience a problem with showing co-hosted events. In fact they don´t show up, when you use a current timestamp for since. The workaround I use is to set the since-value minus (14 * 86400), exp. 14 days in the past. Later in the process I filter the old events by comparing with the real current timestamp. You can check that behaviour by using Insomnia or Postman with the full JSON-Link – at the graph-API site is the problem. I don´t know if a 14 day period is necessary, but it works for us. Kind regards, Dom

        1. Hi @Dom, thanks for sharing your solution. Are the missing co-hosted events recurring? I encountered a case where you need to query the API with the original event of the recurring event.

      2. No, I our case for the upper solution we had no recurring events that were affected. But I´m interested in the process you mentioned for recurring events, because it seems that only the first of the recurring events shows up unless it´s finished. Thx and regards, Dom

  212. Dominik Hils Avatar
    Dominik Hils

    Hi, for some reason I´m actually not able to use “file_get_contents” for the API Url. Just wanted to say that curl works:

    $json_link = “https://graph.facebook.com/v13.0/{$fb_page_id}/events/attending/?fields={$fields}&access_token={$access_token}&since={$since_unix_timestamp}&until={$until_unix_timestamp}”;

    $curl = curl_init();

    curl_setopt_array($curl, [
    CURLOPT_URL => $json_link,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => “”,
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => “GET”,
    CURLOPT_POSTFIELDS => “”,
    ]);

    $response = curl_exec($curl);
    curl_close($curl);

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

    Hope it helps. Regards Dom

    1. Hi @Dominik, thanks for sharing what works for you! I’m sure this will help others who have the same issue.

  213. Is there any possibility to import all Facebook events from all countries

    1. Hi Bitrixis, sorry, that is not possible. You can only import events from Facebook pages that you are an admin of.

Leave a Reply

Your email address will not be published. Required fields are marked *