Skip to content
This repository was archived by the owner on Feb 21, 2019. It is now read-only.

Commit 3874c74

Browse files
authored
Merge pull request #5 from shaisachs/feature/findGroups
Add support for find/groups
2 parents 229b409 + 9bb37af commit 3874c74

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

findGroups.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
from __future__ import with_statement
3+
4+
# eg: python findGroups.py --apikey=$myKey --radius=10 --zip=02143 --text="python"
5+
# get your key at https://secure.meetup.com/meetup_api/key/
6+
7+
import meetup_api_client as mac
8+
from meetup_api_client import *
9+
from optparse import OptionParser
10+
11+
if __name__ == '__main__':
12+
option = OptionParser('%prog --apikey --zip --radius --text')
13+
option.add_option('--apikey', dest='apikey',
14+
help='API key')
15+
option.add_option('--zip', dest='zip',
16+
help='Zip code used for radial search')
17+
option.add_option('--radius', dest='radius',
18+
help='Radius to search in miles')
19+
option.add_option('--text', dest='text',
20+
help='Text to search for in group name / description')
21+
(options, args) = option.parse_args()
22+
23+
client = mac.Meetup(options.apikey)
24+
groups = client.find_groups(zip=options.zip, radius=options.radius, text=options.text, order="members")
25+
26+
for group in groups:
27+
print str(group['id']) + ': ' + group['name'] + ' (' + str(group['members']) + ' members)'
28+

meetup_api_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
COMMENTS_URI = 'comments'
4444
PHOTO_URI = '2/photo'
4545
MEMBER_PHOTO_URI = '2/member_photo'
46+
FIND_GROUPS_URI = 'find/groups'
4647

4748
API_BASE_URL = 'http://api.meetup.com/'
4849

@@ -102,6 +103,9 @@ def post_photo(self, **args):
102103
def post_member_photo(self, **args):
103104
return self._post_multipart(MEMBER_PHOTO_URI, **args)
104105

106+
def find_groups(self, **args):
107+
return self._fetch(FIND_GROUPS_URI, **args)
108+
105109
def args_str(self, url_args):
106110
if self.api_key:
107111
url_args['key'] = self.api_key
@@ -110,6 +114,7 @@ def args_str(self, url_args):
110114
def _fetch(self, uri, **url_args):
111115
args = self.args_str(url_args)
112116
url = API_BASE_URL + uri + '/' + "?" + args
117+
113118
logging.debug("requesting %s" % (url))
114119
return parse_json(self.opener.open(url).read())
115120

0 commit comments

Comments
 (0)