Created
October 17, 2015 13:27
-
-
Save shashank88/cd1ea5478fd4d3aa2994 to your computer and use it in GitHub Desktop.
birthday autoposter
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
from facepy import GraphAPI | |
import datetime | |
import random | |
oauth_token = 'FB_API_KEY ' | |
graph = GraphAPI(oauth_token) | |
friend_list = graph.get("me/friends?fields=birthday,name") | |
wishes_list = ["happy birthday!", | |
"Have a great day!", | |
"Many happy returns of the day!", | |
"Have a great year ahead!", | |
] | |
now = datetime.datetime.now().strftime("%m-%d") | |
month_day = now.split('-') | |
for friend in friend_list['data']: | |
if friend.has_key('birthday'): | |
b_date = friend['birthday'].split('/') | |
if b_date[0] == month_day[0] and b_date[1] == month_day[1]: | |
random_wish = wishes_list[random.randint(0, len(wishes_list) -1) ] | |
graph.post(friend['id']+ '/feed', 0, message = bday_wish) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment