views:

780

answers:

2

I am attempting to add functionality to my Django app: when a new post is approved, I want to update the corresponding Facebook Page's status with a message and a link to the post automatically. Basic status update.

I have downloaded and installed pyfacebook - and I have read through the tutorial from Facebook. I have also seen this suggestion here on SO:

import facebook
fb = facebook.Facebook('YOUR_API_KEY', 'YOUR_SECRET_KEY')
fb.auth.createToken()
fb.login() # THIS IS AS FAR AS I CAN GET
fb.auth.getSession()
fb.set_status('Checking out StackOverFlow.com')

When I get to the login() call, however, pyfacebook tries to open lynx so I can login to Facebook 'via the web' -- this is, obviously, not going to work for me because the system is supposed to be automated ... I've been looking, but can't find out how I can keep this all working with the script and not having to login via a web browser.

Any ideas?

+2  A: 

In the definition of login, particularly in the docstring, it appears as though the intended behavior is to open up a browser in order to have you log in that way.

def login(self, popup=False):
    """Open a web browser telling the user to login to Facebook."""
    import webbrowser
    webbrowser.open(self.get_login_url(popup=popup))

Looking at the facebook page User:PyFacebook_Tutorial that you linked, it looks like the example with login is a "Desktop Applications" example. You want to follow the "Web Applications" section. I'd encourage you to simply press ahead with the tutorial there.

Ewan Todd
There is an explanation further down at: http://wiki.developers.facebook.com/index.php/User:PyFacebook_Tutorial#Adding_content_to_a_profile_page_without_user_interaction.2Flogin ... however, a note says that the method is currently 'overkill' ... was hoping someone had the experience to share that may help out ... otherwise, will try that route.
thornomad
The comment is that the "infinite session key trick" is overkill. I would still be inclined to follow the tutorial first, just to make it work. You can follow the session key advice after you have gained a feel for the API.
Ewan Todd
Haven't managed to post yet, but this was helpful: http://www.emcro.com/blog/2009/01/facebook-infinite-session-keys-no-more/
thornomad
A: 

doesn't work again now isn't it ?

Gunslinger_