justb3a Posted March 10, 2017 Share Posted March 10, 2017 FacebookEvents ProcessWire module to get Facebook Page Events using the Graph API. Create an app on Facebook developers website You have to create an app to get appId and appSecret. Those keys are required. Go to Facebook Developers and add a new app. Congrats! Now you can copy your Facebook appId and appSecret. Get your Facebook page ID You can either enter your facebook page ID or the facebook page name. If you enter the Facebook page name, this module will get the page ID for you! Call Module $events = $modules->get('FacebookEvents')->getEvents(); Output Events {% for event in events|reverse %} {% if event.start_time|date('U') > date().timestamp %} <div> {% set dts = modules.get('FacebookEvents').getDates(event) %} <a href="https://www.facebook.com/events/{{event.id}}/" title="Facebook">{{dts.dates}}:</a> {{event.name}} <em>{{dts.times}}</em> </div> {% endif %} {% endfor % 21 Link to comment Share on other sites More sharing options...
ngrmm Posted May 10, 2017 Share Posted May 10, 2017 is there a way to get also the event-venue? Link to comment Share on other sites More sharing options...
justb3a Posted May 10, 2017 Author Share Posted May 10, 2017 At the moment the endpoint just returns: id, name, timezone, start_time, end_time, description. But it's pretty easy to get the information about the place and cover. I updated the module to include it as well and updated the Graph Api Version to 2.9. `$modules->get('FacebookEvents')->getEvents()` returns now the following data: array(1) { [0]=> array(6) { ["id"]=> string(15) "123123123" ["name"]=> string(3) "xxx" ["timezone"]=> string(13) "Europe/Berlin" ["start_time"]=> string(24) "2017-06-23T16:00:00+0200" ["end_time"]=> string(24) "2017-06-23T18:30:00+0200" ["description"]=> string(3) "foo", ["place"]=> array(3) { ["name"]=> string(5) "Venue" ["location"]=> array(6) { ["city"]=> string(7) "Berlin" ["country"]=> string(7) "Germany" ["latitude"]=> float(xx.3321915) ["longitude"]=> float(xx.3735704) ["street"]=> string(17) "Street 14" ["zip"]=> string(5) "01234" } ["id"]=> string(15) "123123123" } ["cover"]=> array(4) { ["offset_x"]=> int(0) ["offset_y"]=> int(85) ["source"]=> string(148) "https://scontent.xx.fbcdn.net/v/t31.0-8/s720x720/..." ["id"]=> string(16) "123123123" } } } Having a quick look at the Graph API documentation, using the event ID one could send another request to get even more data. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api/reference/event/. 2 Link to comment Share on other sites More sharing options...
ngrmm Posted May 13, 2017 Share Posted May 13, 2017 ok thx justb3a i'll try that. could you help me with outputing the dates. i'm a php-beginner and can't output the events. your code above is written in twig, is that an engine? anyway i tried it like this: <?php $events = $modules->get('FacebookEvents')->getEvents(); echo "<ul>"; foreach($events as $event) { echo "<li>$event->name</li>"; } echo "</ul>"; ?> but i don't get any ouput from this. maybe i did something wrong while creating the facebook-app. i added the ID and SECRET into the module and the page-name. but the module doesnt add the page-ID automatically! do i have to be the owner of the facebook-page which events i want to get? Link to comment Share on other sites More sharing options...
justb3a Posted May 14, 2017 Author Share Posted May 14, 2017 The workflow is as follows: Enter Client ID and Secret Enter Page Name OR Page ID: If you enter the Page Name, make sure to copy it from the Facebook page url similar to `https://www.facebook.com/NameWithoutSpaces` => NameWithoutSpaces would be the Page Name Add `$events = $modules->get('FacebookEvents')->getEvents();` to a template and open the belonging page (frontend) Go back to module settings and check (reload before) if a page id has been added. If not, your page name could not be resolved. Now you should be able to receive events: $events = $modules->get('FacebookEvents')->getEvents(); echo "<ul>"; foreach ($events as $event) { echo "<li>{$event['name']}</li>"; } echo "</ul>"; $events is an array, so you have to use the following syntax: `$event['propertyName']`. I found a little bug and updated the module, so please make sure to get the latest version. 2 Link to comment Share on other sites More sharing options...
ngrmm Posted May 14, 2017 Share Posted May 14, 2017 On 5/14/2017 at 10:50 AM, justb3a said: $events is an array, so you have to use the following syntax: `$event['propertyName']`. Expand that was it! thx, great module! there should be a „buy-me-a-beer“-button (flattr, paypal, …)! Link to comment Share on other sites More sharing options...
ngrmm Posted June 1, 2017 Share Posted June 1, 2017 me again, everything worked fine. at first the cache was set to now. then i changed that to daily and moved the website to another directory. since then module doesn't get newly added events. it seems the old data is stored somewhere an no updates are possible. i created a new app and tried it different APP-ID and had no luck. i still get data output when the APP-ID, APP-SECRET and Facebook-Name-Fields are empty !? and i don't use any other cache-modules am i doing something wrong? Link to comment Share on other sites More sharing options...
justb3a Posted June 1, 2017 Author Share Posted June 1, 2017 Have a look at your caches table. Search for name=Module.FacebookEvents. Delete this row. Furthermore you could have a look at your modules table where class=FacebookEvents, column: data. 1 Link to comment Share on other sites More sharing options...
ngrmm Posted June 1, 2017 Share Posted June 1, 2017 it suddenly works now, i think the 24h were over since the last update. i'll have look at the tables next time. thx Link to comment Share on other sites More sharing options...
ngrmm Posted June 1, 2017 Share Posted June 1, 2017 it works now, but it seems that there is limit. facebook API only returns 25 events. i found this solution: https://stackoverflow.com/questions/4752967/facebook-api-only-returns-25-events-max but this is too advanced for me. i don't now how and where to set the limit to 50 or more. Link to comment Share on other sites More sharing options...
ngrmm Posted June 1, 2017 Share Posted June 1, 2017 ah changed line:29 in FacebookEvents.module to: const FB_PAGEEVENTS_URL = '%sv%s/%s/events/?fields=%s&access_token=%s&since=%s&until=%s&limit=50'; Link to comment Share on other sites More sharing options...
Tacolombardi Posted June 8, 2017 Share Posted June 8, 2017 Hi, this is all working fine for me, nice module! I have one question: is it also possible to display the image of the event? I think i should use "Cover" and "Source" but i'm not that good with php so I don't know in what sentence to use it.. Link to comment Share on other sites More sharing options...
justb3a Posted June 8, 2017 Author Share Posted June 8, 2017 @ngrmm It's never a good idea to override somehing in the core or in a third-party module because if you update it your changes are overritten again. I updated the module and added an option in module settings to set the limit. @Tacolombardi <?php $events = $modules->get('FacebookEvents')->getEvents(); ?> <ul> <?php foreach ($events as $event): ?> <li> <?=$event['name']?> <img src="<?=$event['cover']['source']?>" alt="<?=$event['name']?>" /> </li> <?php endforeach; ?> </ul> 3 Link to comment Share on other sites More sharing options...
ngrmm Posted June 25, 2017 Share Posted June 25, 2017 On 6/1/2017 at 6:32 AM, justb3a said: Have a look at your caches table. Search for name=Module.FacebookEvents. Delete this row. Furthermore you could have a look at your modules table where class=FacebookEvents, column: data. Expand still having problems. newly added events won't show up in frontend. i guess this has something to do with cache/tables. i have to delete it manually, is there a way the module would do that automatically? Link to comment Share on other sites More sharing options...
Macrura Posted July 25, 2017 Share Posted July 25, 2017 What i did was to make the Page ID field editable, that was the only way to test the module with a dummy events feed and then switch it out to a different page; the clear module cache select item is not working for some reason... in line 66 of the FacebookEventsConfig.php you can comment out this: $field->collapsed = Inputfield::collapsedNoLocked; ... ... I made some other changes to the module to allow the users to configure the since date, and until date; Once that's all stable i'll hopefully do a pull request on github for the extended features; and if i can figure out how to make it update the ID of the page if the cache is set to expire now, i'll post back here.. Link to comment Share on other sites More sharing options...
justb3a Posted July 25, 2017 Author Share Posted July 25, 2017 @Macrura Are you using the latest version? I fixed a little bug just a few weeks ago. Looking forward to merge your PR Link to comment Share on other sites More sharing options...
Lance O. Posted August 7, 2017 Share Posted August 7, 2017 What about this module makes to specific to PW 3.x and above? I would like to be able to use it on site using PW 2.7.2. Link to comment Share on other sites More sharing options...
justb3a Posted August 7, 2017 Author Share Posted August 7, 2017 On 8/7/2017 at 2:37 PM, Lance O. said: What about this module makes to specific to PW 3.x and above? I would like to be able to use it on site using PW 2.7.2. Expand This module uses namespaces which has been introduced with PW 3. I upgraded all my projects to PW 3.x, so I have no need to test and support older versions. 1 Link to comment Share on other sites More sharing options...
Lance O. Posted August 7, 2017 Share Posted August 7, 2017 Thanks for the quick response! Link to comment Share on other sites More sharing options...
silvestro Posted October 27, 2017 Share Posted October 27, 2017 This may be a dumb question, but how do I get past events? With normal usage I just get the future events, but when I modify the module at the getEvents() function and set the $sinceDate to 0, I get all past events aswell. Am I missing an implemented solution intended by @justb3a? Link to comment Share on other sites More sharing options...
Macrura Posted October 27, 2017 Share Posted October 27, 2017 you can't get past events, but you can try the forked version which has a few extra options... (date since, date until, reverse sort)... https://github.com/outflux3/processwire-facebookevents planned to do a PR but haven't gotten round to it yet.. 2 Link to comment Share on other sites More sharing options...
silvestro Posted October 28, 2017 Share Posted October 28, 2017 Thanks for your reply, that works great! Link to comment Share on other sites More sharing options...
Macrura Posted October 28, 2017 Share Posted October 28, 2017 ok cool -thanks for testing out my version! i will be submitting a PR soon so once that happens and if it is accepted you could switch back to the official branch; but if it works for you and satisfies your current requirements, it should be 'stable', there are just a few simple changes to the code and those added inputfields. if you do run into any issues, you can post an issue on the forked github issues page.. Link to comment Share on other sites More sharing options...
justb3a Posted November 4, 2017 Author Share Posted November 4, 2017 On 10/28/2017 at 3:39 PM, Macrura said: i will be submitting a PR soon so once that happens and if it is accepted you could switch back to the official branch; but if it works for you and satisfies your current requirements, it should be 'stable', there are just a few simple changes to the code and those added inputfields. if you do run into any issues, you can post an issue on the forked github issues page.. Expand I created a "Pull Request" at my own and extended the module config, so one is able to define a date range and reverse sorting. Thanks @Macrura 4 Link to comment Share on other sites More sharing options...
ngrmm Posted April 15, 2018 Share Posted April 15, 2018 all of a sudden module stopped working. i do not use any caching. i'm a bit puzzeld what happened any changes from facebook? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now