Use a REST API: Difference between revisions
Content added Content deleted
(Adding a way to add lat/lon in the Javascript version) |
(Adding a method to create venues.) |
||
Line 325: | Line 325: | ||
} |
} |
||
var |
var get = function(params, callback, path) { |
||
params.key = key; |
params.key = key; |
||
Line 340: | Line 340: | ||
var |
var post = function(details, callback, path) { |
||
details.key = key; |
details.key = key; |
||
request.post({ |
request.post({ |
||
headers: { 'content-type' : 'application/x-www-form-urlencoded' }, |
headers: { 'content-type' : 'application/x-www-form-urlencoded' }, |
||
url: url + '/2/event', |
url: url + (path || '/2/event'), |
||
form: details |
form: details |
||
}, function(err, res, body) { |
}, function(err, res, body) { |
||
Line 353: | Line 353: | ||
var parseEvent = function(mEvent) { |
var parseEvent = function(mEvent) { |
||
/* |
|||
* A simple function that converts JSON to |
|||
* string in a pretty way |
|||
**/ |
|||
var name = mEvent['name'] || ''; |
var name = mEvent['name'] || ''; |
||
var desc = mEvent['desc'] || ''; |
var desc = mEvent['desc'] || ''; |
||
Line 388: | Line 392: | ||
return { |
return { |
||
get: get, |
|||
parseEvents: parseEvents, |
parseEvents: parseEvents, |
||
post: post |
|||
} |
} |
||
} |
} |
||
Line 396: | Line 400: | ||
meetup(). |
meetup().get({ |
||
⚫ | |||
topic: 'photo', |
topic: 'photo', |
||
city: 'nyc' |
city: 'nyc' |
||
Line 412: | Line 417: | ||
* Running the code below with the group name will give the group ID, an integer. |
* Running the code below with the group name will give the group ID, an integer. |
||
meetup(). |
meetup().get({ |
||
'group_urlname': 'foodie-programmers' |
'group_urlname': 'foodie-programmers' |
||
}, function(group) { |
}, function(group) { |
||
Line 420: | Line 425: | ||
* Using the above group_id and the group_urlname manually, |
* Using the above group_id and the group_urlname manually, |
||
* you can post events to a group with the below code |
* you can post events to a group with the below code |
||
*/ |
**/ |
||
⚫ | |||
// More Info: http://www.meetup.com/meetup_api/docs/:urlname/venues/#create |
|||
name: 'Finding Nemo', |
|||
address_1: 'p sherman 42 wallaby way sydney', |
|||
city: 'sydney', |
|||
country: 'australia', |
|||
// state: needed if in US or CA. |
|||
}, function(venue) { |
|||
console.log('Venue: ', venue, venue.id); |
|||
// Prints a venue ID that can be used to create a event |
|||
}, '/' + '{{ foodie-programmers }}' + '/venus'); |
|||
// This needs a valid urlname for the group |
|||
⚫ | |||
meetup().post({ |
|||
⚫ | |||
// More Info: http://www.meetup.com/meetup_api/docs/2/groups/ |
|||
group_id: 42, // Group ID goes here |
group_id: 42, // Group ID goes here |
||
group_urlname: 'foodie-programmers', |
group_urlname: 'foodie-programmers', |
||
Line 433: | Line 451: | ||
why: 'We should do this because... Less than 250 characters', |
why: 'We should do this because... Less than 250 characters', |
||
hosts: 'up to 5 comma separated member ids', |
hosts: 'up to 5 comma separated member ids', |
||
venue_id: |
venue_id: 42, // Integer, ID of venue. Venue can be created with the above. |
||
lat: |
lat: 42, // Latitude, Integer |
||
lon: |
lon: 42, // Longitude, Integer |
||
simple_html_description: 'Event description in <b>simple html</b>. Less than <i>50000</i> characters.' |
simple_html_description: 'Event description in <b>simple html</b>. Less than <i>50000</i> characters.' |
||
}, function(result) { |
}, function(result) { |
||
console.log(result); |
console.log('Event: ', result); |
||
})</lang> |
})</lang> |
||