facebook-birthday-response icon indicating copy to clipboard operation
facebook-birthday-response copied to clipboard

Change the calls according to Facebook's changed API and rate limits

Open rishirdua opened this issue 9 years ago • 7 comments

Creating the issue to keep track. Not planning to fix this myself in the near future. Feel free to own and solve.

rishirdua avatar Apr 28 '16 06:04 rishirdua

I have a small doubt in what you have written : if comment: reply = choice(message_set) print 'Replying %s to %s' % (reply, wish['from']) url = 'https://graph.facebook.com/%s/comments?access_token=%s' % (wish['id'], access_token) requests.post(url, data={'message': reply}, proxies=proxy_dict)

Isn't this supposed to be iterating over "post"

print 'Replying %s to %s' % (reply, post['from']) url = 'https://graph.facebook.com/%s/comments?access_token=%s' % (post['id'], access_token)

Just wondering if this did work for you without the above change ?

JaharshKotha avatar Feb 11 '17 06:02 JaharshKotha

Wrote it long time ago back in school.

Definitely worked for me as I used it on my birthday

rishirdua avatar Feb 17 '17 21:02 rishirdua

Haha ,I was expecting this , I was hesitant to ask but just gave it a shot .

JaharshKotha avatar Feb 17 '17 21:02 JaharshKotha

hey! how ur accessing the tokens i mean i went to the link u mentioned logged in and then checked in the boxes manage_pages and publish_pages, then the token generated gets expired every time..thanks

bc206 avatar Feb 22 '17 09:02 bc206

After some minor modifications, I was able to get this code functional again.

  • Regarding JaharshKotha's post, the answers is yes, in the current version, you are iterating with post but accessing "wish". I changed the "wish" occurrences with "post", this was easy as you would get a very explicit error.

  • Regarding the facebook changed API, I had to modify the params line with the following: "params = {'since': utc_bday, 'access_token': access_token, 'fields': 'id,message,from,name,type'}". Apparently, now you just get a couple fields by default and you must explicitly specify the fields you want to receive.

  • The like functionality is no longer supported by the API: https://developers.facebook.com/bugs/1754734484744033/

  • I also had a problem testing this code with only one post, when assigning next_url. As this was my first test, I don't know if this was happening in cases with multiple posts. Anyway, to solve that error, I added a try catch block when we assign next_url. I catch the exception KeyError and return "wishes".

Think that's it... Successfully tested right now.

jpdias92 avatar Sep 13 '17 01:09 jpdias92

@Fernuts92 Awesome, do you want to send a Pull Request and fix this for everyone?

rishirdua avatar Sep 13 '17 01:09 rishirdua

@rishirdua I have worked out my own code long back after I had issues with yours , would you like to test and pull it in ? https://github.com/JaharshKotha/Fb-birthday-bot

JaharshKotha avatar Sep 13 '17 01:09 JaharshKotha