Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

Meetup API Event List

Summary: Adds Meetup API to PmWiki pages
Version: 2014-02-21
Prerequisites: PHP 5 >= 5.2.0
Maintainer: StefCT

GitHub Repository: github.com/stefct/MeetupAPIEventList

Categories: Integration, Includes, PHP55
Licence: GPL
Users: +1 (view / edit)

Questions answered by this recipe

How can I embed an event list from the Meetup API into PmWiki pages and format it with PmWiki markup?

Description

The Meetup API provides a simple interface for accessing the Meetup platform from your own apps. With this recipe, you can include a list of upcoming Meetup events into your PmWiki pages (e.g. for a selected group), using the events method of Meetup API. See examples below for usage.

How to Install

  • Download MeetupAPIEventList.zipΔ and unpack it in your PmWiki directory.
  • In your local config, write the usual include code:
    require_once "$FarmD/cookbook/meetupinc.php";
  • Generate a signed URL for your Meetup API request (see below) and include it into your local config using the following code:
    $MeetupURL = "Your_Signed_URL";
  • Configure caching functionality

How to Obtain a Signed Meetup URL

  • Visit http://www.meetup.com/meetup_api/console/?path=/2/events and sign in with your account
  • Enter your data (usually group_urlname should be sufficient, e.g. "nylug-meetings", but other criteria is possible too) and click "Show Response"
  • Copy and paste signed URL (should be displayed right below the input form) into your local config as described above

Meetup API Troubleshooting

  • Meetup user account required
  • Check whether all required data is displayed below the input form
  • Make sure that format=json is part of the signed URL
  • URL should look something like
    http://api.meetup.com/2/events?group_id=2659922&status=upcoming&order=time&limited_events=False& desc=false&offset=0&format=json&page=200&fields=&sig_id=xxxxxxxx&sig=yyyyyyyyyyyyyy

Usage

If this looks too complicated, please check out the examples below! Most of them should work out of the box using copy and paste.

Meetup data is included with the markup

(:meetupinc Custom Variables and Formatting:)

Plain text and some basic PmWiki markup (like ''' for bold, [[<<]] for linebreaks and [[http://example.com/]] for hyperlinks) can be used.

To display Meetup data, use the following custom variables:

  • {$$m-name} for event name
  • {$$m-desc} for event description (enabling UTF-8 might be necessary for this to work properly, and you might also want to try setting text_format to "plain" in your Meetup query)
  • {$$m-g-name} for name of your Meetup group
  • {$$m-g-id} for id of your Meetup group (useful for testing and other internal purposes)
  • {$$m-v-name} for name of event location
  • {$$m-v-addr} for location address
  • {$$m-v-city} for city
  • {$$m-v-state} for state
  • {$$m-v-country} for country
  • {$$m-weekday} for weekday, according to your locale (e.g. "Thursday", "jeudi", "Donnerstag")
  • {$$m-day} for day
  • {$$m-year} for year (four digits)
  • {$$m-month} for month (e.g. "8" for "August")
  • {$$m-month-text} for name of the month, according to your locale (e.g. "January", "janvier", "January")
  • {$$m-time-ampm} for time in 12 hours format (e.g. "2:30 pm")
  • {$$m-time} for time in 24 hours format (e.g. "14:30")
  • {$$m-link} for a link to the event's Meetup page
  • {$$m-todaytom} to include "Today, " if the event starts today or "Tomorrow, " if it starts tomorrow


Limiting the Number of Results

By default, (:meetupinc:) lists all events that were returned by the Meetup API query. You can limit the number of results with the (:meetupparams:) directive which needs to be included before (:meetupinc:) markup:

(:meetupparams max=Maximum Number of Events Displayed:)

If you want to display only the next upcoming event, use:

(:meetupparams max=1:)

Reset the maximum to unlimited with:

(:meetupparams max=0:)

If you want to skip a certain number of events at the beginning of the list, use:

(:meetupparams min=Number of the First Event to be Displayed:)

Caching

In order to speed up the website and to avoid exceeding Meetup's API limit, this recipe writes Meetup data to cache (if possible). By default, cache is being updated every 10 minutes.

For caching to work properly, you need to create a folder named "meetupcache" in your main PmWiki directory which needs to be writable by www-data (or whatever user it is as which your web server runs).

You can change the location of the cache file by changing $CacheFile = "meetupcache/meetup-cache.json"; to something else in meetupinc/meetuplib.php.

Cache duration can be modified in your local config file. If you want it to be 5 minutes instead of 10, simply add the line $MeetupCacheLifetime = 300; to your config. This line needs to be included before require_once "$FarmD/cookbook/meetupinc.php" to work properly.

How to Include Multiple Groups

The events method of Meetup API allows you to include multiple groups with a single query. This can be done by using the field group_id in http://www.meetup.com/meetup_api/console/?path=/2/events.

If you know a certain group's URL name, you can determine its group id with http://www.meetup.com/meetup_api/console/?path=/2/groups (Meetup login required). Simply enter your group's urlname in the corresponding field (e.g. "nylug-meetings"), add "id" to the field named "only", hit "Show Response", and copy the id (e.g. "2659922") from the gray area below.

In the field group_id in http://www.meetup.com/meetup_api/console/?path=/2/events, you can now combine multiple group ids separated by commas (e.g. "2659922,1556336"). Then hit "Show Response" and obtain your signed Meetup URL. This can be included in your local config as described above.

List events of selected groups

By default, (:meetupinc:) lists all events of all groups from the original API query in chronological order. You can use the (:meetupparams:) directive to limit the results to a selected group. It needs to be included before (:meetupinc:) markup:

List only events of the group with the id 2659922 (the option groupflag=true could be omitted because it is default behavior):

(:meetupparams groupid=2659922 groupflag=true:)

Exclude events of the group with the id 2659922 while displaying all other events:

(:meetupparams groupid=2659922 groupflag=false:)

Display all events of all groups (reset to default) with:

(:meetupparams groupid=-1:)

Other Advanced Options

Display Events at Selected Venues

By default, (:meetupinc:) lists all events at all the venues from the original API query. You can use the (:meetupparams:) directive to limit the results to a selected venue. It needs to be included before (:meetupinc:) markup:

List only events at the venue with the venue id 4957192 (the option venueflag=true could be omitted because it is default behavior):

(:meetupparams venueid=4957192 venueflag=true:)

Exclude events at the venue with the id 4957192:

(:meetupparams venueid=4957192 venueflag=false:)

Display all events at all venues (reset to default) with:

(:meetupparams venueid=-1:)

Examples

The following markup:

(:meetupparams max=1:)!!!Next Event:
(:meetupinc '''{$$m-name}''' [[<<]]{$$m-todaytom} {$$m-weekday} {$$m-month-text} {$$m-day}, {$$m-time-ampm}[[<<]]{$$m-v-name}, {$$m-v-addr}, {$$m-v-city}, {$$m-v-state}[[<<]][[{$$m-link}|Sign up on Meetup]] [[<<]]:)

yields something like the following output:

Next Event:

An overview of MySQL forks and alternative Storage Engines
Thursday June 13, 6:30 pm
Google Chelsea Market Office, 75 Ninth Ave, Floor 2, New York, NY
Sign up on Meetup

List some more events with this markup:

(:meetupparams min=2 max=5:)!!!More Events:
(:meetupinc {$$m-month-text} {$$m-day}, {$$m-time-ampm}: [[{$$m-link}|{$$m-name}]][[<<]]:)

Output:

Use the following markup to list all remaining events (e.g. in a separate Wiki page):

(:meetupparams min=6 max=0:)!!!Even More Events:
(:meetupinc {$$m-month-text} {$$m-day}, {$$m-time-ampm}: [[{$$m-link}|{$$m-name}]][[<<]]:)

Release Notes

2013-07-09:

  • Recipe now compatible with PHP 5.5

2013-07-09:

  • Multiple groups functionality added
  • Some refactoring of meetuplib.php and meetupinc.php; faciliating the use of meetuplib.php outside of PmWiki
  • All PmWiki markup from v0.1 should work fine with this version

v0.1 (2013-06-15): Initial release

Contributors

StefCT

Comments

See discussion at MeetupAPIEventList-Talk?

User notes +1: If you use, used or reviewed this recipe, you can add your name. These statistics appear in the Cookbook listings and will help newcomers browsing through the wiki.

Edit - History - Print - Recent Changes - Search
Page last modified on July 09, 2014, at 12:59 PM