开发者

Programmatically login to Facebook using username/password

开发者 https://www.devze.com 2023-04-10 09:06 出处:网络
Ok, I\'ve been looking for over an hour on this subjec开发者_StackOverflow中文版t and can only find OAuth solutions, which I do not need or want.

Ok, I've been looking for over an hour on this subjec开发者_StackOverflow中文版t and can only find OAuth solutions, which I do not need or want.

I need to authenticate as myself to Facebook from a location other than Facebook. I need my website (admin area) to authenticate to Facebook for me and post in my behalf, on my wall, or my friends wall. This is an administration tool, and I don't want to login into Facebook every time I post to my website. I need this admin extension to login for me, and add an automated post with a title and image: "New post on example.com".

It feels like I've been looking everywhere and can only find solutions with creating a FB application, granting it certain rights, using oauth, etc-overly-complicated-process, which is (dare-i-say) rather stupid since I don't want to authenticate other people, like visitors. I simply want to emulate my(self|browser), as if I'm the one navigating through their pages and not an automated tool. Of course I could probably go the cURL way and emulate a real user-agent but I'm not about to start scraping FB pages.

Is there a programmatic way of authenticating to FB using a simple user/pass (not even stored on the server) and get the same rights I normally get when authenticating through a browser? And of course, obtain needed data in a json or other machine parse-able encapsulation ? I would assume I need to send a cookie or some form of token on susequent requests, but that's not a problem, I just need a way of authenticating with a simple user/pass and bypass that whole app registration ache.

I'd need something similar to twitter and google+ maybe (?) I did find a simple class for twitter but nothing on google+ (same problem, twitter is pushing hard for their way of creating an app and using oauth, but they do maintain a way of authenticating as yourself through simple REST requests).


I don't believe there is a way to do what you're describing, other than a painful and non-supported method of emulating a user agent. It's also not a good practice to do what you're describing, as Facebook (and other websites for that matter) should not allow 3rd parties to collect usernames/passwords, even if it's only in transit. I understand that in your scenario, you will be the only user, but Facebook has to design their API for the masses.

Why not set up a Facebook App and use oauth? You'll only need to authorize your App once, get an offline access token, and then use that access token from then on. I think this will be easier than the approach you're looking for because you won't need to authenticate with Facebook every time. You just need the access token.

Note that the offline access token will expire if you change your Facebook password or you de-authorize your app.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号