1

我正在尝试将 Facebook 与 FacePy 集成并得到错误FacebookError at / No exception supplied。该请求通过 curl 在命令行上运行,并且实际上在 Facebook 上发布,所以我知道权限和访问令牌是正确的。如果我删除 graph.post 行,则不会引发错误,因此我认为它必须由实际的发布尝试触发。顺便说一句,我正在本地开发。我已经让 django-facebook 在本地工作,所以这应该不是问题。我究竟做错了什么?谢谢

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)

错误:

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
4

2 回答 2

3

原来是Facebook权限错误。发现获得正确的权限很棘手。我发现这有助于获得具有最广泛权限的访问令牌:https ://developers.facebook.com/tools/explorer

于 2012-09-22T15:14:17.700 回答
0

请求方法应该是 request.POST 而不是 GET,因为您要发布到 Facebook Graph。

于 2012-09-22T03:09:32.573 回答