Reputation: 21
I need to update my Facebook Fan Page in a django app so I have this code:
import facebook
from django.conf import settings
def login_facebook():
fb = facebook.Facebook(settings.FACEBOOK_API_KEY, settings.FACEBOOK_SECRET_KEY)
fb.session_key = settings.FACEBOOK_SESSION
fb.secret = settings.FACEBOOK_SECRET_KEY
fb.uid = settings.FACEBOOK_UID
return fb
def update_status(fb, message):
return fb.stream.publish(message=status_message)
And I use this to run it with ipython:
import src.tests.scripts.facebook_publish_fanpage as f
fb = f.login_facebook()
f.update_status(fb, 'This is a test')
But I get this exception:
AttributeError: 'Facebook' object has no attribute 'stream'
I already gave permissions to the app following this 2 steps:
Publish post on Facebook page(1) and Authorizing a Facebook Fan Page for Status Updates(2)
But no matter what I try (being doing it a few hours now...) I can't publish to the page...
I'm lost now, any help?
(1) tech.karolzielinski.com/publish-post-of-facebook-page-wall-as-a-page-not-a-user-python-facebook-rest-api
(2) stackoverflow.com/questions/2097665/authorizing-a-facebook-fan-page-for-status-updates
PD: Sorry don't have permission to add the links yet, I'm mostly a reader in SO
Upvotes: 1
Views: 1922
Reputation: 21
After searching for hours I finally found the solution... not to use stream methods but this:
fb(method='stream_publish', args={'session_key': settings.FACEBOOK_SESSION, 'uid':PAGE_ID, 'target_id': 'NULL', 'message':'MESSAGE_HERE'})
Found the solution at this blog post: http://danielquinn.org/blog/1578.html
That works!!
Upvotes: 1