Facebook Graph API & django-facebook - posting links and photos to page feeds -
@facebook_required_lazy(scope=['manage_pages', 'publish_stream', 'photo_upload']) def index(request): if request.method == 'post': form = cpyposterform(request.post) if form.is_valid(): fb = require_persistent_graph(request) msg = form.cleaned_data['msg'] pages = form.cleaned_data['pages'] res = dict() p in pages: try: key = page_choices[p] except keyerror: key = p res[key] = fb.set('{page_id}/feed'.format(page_id=p), message=msg)
i'm trying post feeds of multiple pages. when post simple text, no problem. however, when attempt upload photo or link, item posted feed, it's "recent posts others" section , not page feed itself.
it gets posted me , not page. there need special post item in pages feed (as page) link and/or photo?
facebook graph api php sdk posting on page page
found it. there different access token impersonating page post as page. /me/accounts , use token post page. updated working code:
@facebook_required_lazy(scope=['manage_pages', 'publish_stream', 'photo_upload']) def index(request): if request.method == 'post': form = cpyposterform(request.post) if form.is_valid(): fb = require_persistent_graph(request) msg = form.cleaned_data['msg'] pages = form.cleaned_data['pages'] me_accounts = fb.get('/me/accounts') access_token = none resp = dict() p in pages: d in me_accounts['data']: if d['id'] == p: access_token = d['access_token'] try: key = page_choices[p] except keyerror: key = p openfb = openfacebook(access_token) resp[key] = openfb.set('{page_id}/feed'.format(page_id=p), message=msg, link='http://www.espn.com')
Comments
Post a Comment