I'm trying to integrate Facebook with FacePy and getting the error FacebookError at / No exception supplied
. The request is working on the command line through curl, and actually posting on Facebook, so I know permissions and access token are correct. If I remove the graph.post line, there is no error thrown, so I reckon it must be triggered by the actual post attempt. I'm developing locally btw. I have got django-facebook working locally, so that shouldn't be a problem. What am I doing wrong? Thanks
from facepy import GraphAPI
@login_required
def index(request):
proposed_event_list = Event.objects.all().filter(date__gt=datetime.now()).annotate(c=Count('userprofile')).filter(c__lt=4).order_by('date')
confirmed_event_list = Event.objects.all().filter(date__gt=datetime.now()).annotate(c=Count('userprofile')).filter(c__gt=3).order_by('date')
past_event_list = Event.objects.all().filter(date__lt=datetime.now()).order_by('date')
graph = GraphAPI("AAAD392hkaGX0BAP0U1IZClcPh6qZCpIZBqiP5ze3ELZB14ZChropfyWT6OeELgfgYiY929Adi90kgLGXdLQ3qOQM0KsjvQ6S9Q4VbuHXwhAZD")
graph.post(path="https://graph.facebook.com/426364711649/feed", retry=1, message="Hello")
context = RequestContext(request)
context['proposed_event_list'] = proposed_event_list
context['confirmed_event_list'] = confirmed_event_list
context['past_event_list'] = past_event_list
return render_to_response('crewcal.html', context)
Error:
FacebookError at /
No exception supplied
Request Method: GET
Request URL: http://localhost:8000/
Django Version: 1.4.1
Exception Type: FacebookError
Exception Location: /usr/local/lib/python2.7/dist-packages/facepy/graph_api.py in post, line 69
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/usr/local/lib/python2.7/dist-packages/requests/packages',
...
'/usr/lib/python2.7/dist-packages/wx-2.8-gtk2-unicode']
Server time: Fri, 21 Sep 2012 18:49:11 -0500
Turned out to be a Facebook permissions error. Finding it tricky to get permissions right. I found this helpful to get an access token with widest permissions: https://developers.facebook.com/tools/explorer
请求方法应该是request.POST而不是GET,因为您要发布到Facebook Graph。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.