Created
November 4, 2014 15:14
-
-
Save shubham1810/a9a6b6866cc08d737542 to your computer and use it in GitHub Desktop.
python script using facebook graph API to know about the events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import facepy, collections, time | |
| token = "XXXX" | |
| def convert(data): | |
| if isinstance(data, basestring): | |
| return str(data) | |
| elif isinstance(data, collections.Mapping): | |
| return dict(map(convert, data.iteritems())) | |
| elif isinstance(data, collections.Iterable): | |
| return type(data)(map(convert, data)) | |
| else: | |
| return data | |
| graph = facepy.GraphAPI(token) | |
| a = graph.get('me/events') | |
| data = convert(a) | |
| f = open("new.txt", "w") | |
| for i in data['data']: | |
| #print i | |
| #print i['name'], i['start_time'] | |
| event_time = i['start_time'].split('T') | |
| print i['name'], event_time | |
| f.write(str(i['name']) + " " + str(event_time)) | |
| f.write("\n") | |
| if(str(event_time[0])==str(time.strftime("%Y-%m-%d"))): | |
| print "EVENT TODAY!!!!" | |
| event_time_value = event_time[1].split('+') | |
| if(str(event_time_value[0])==str(time.strftime("%H:%M%:%s"))): | |
| print "Event now!!" | |
| f.close() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment