Link to home
Start Free TrialLog in
Avatar of mixteral
mixteral

asked on

PHP Login to Twitter without OAuth

Hello,

I need to login to twitter (not mobile version) but can't seem to get it done properly.
As title say, I don't wish to rely on their API to get this working.

I have tried to post via curl the input fields with the right value but the response I get from twitter is still the login page.

Here are the input fields I have identified :

session[username_or_email]
session[password]
redirect_after_login
remember_me
scribe_log
lang
redirect
q
authenticity_token

Open in new window


The "authenticity_token" is dynamically generated, but I'm able to scrape its value without trouble.
"session[username_or_email]" & "session[password]" should contain login details of a twitter account.

I think problem with my code is managing cookies as well as what to do with input field that don't have a "value" attribute ?

Thank's
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Just curious... Why not use their API?  API code is usually versioned and stable, whereas anything you scrape (especially from a dynamic service like Twitter) could change at any time without notice.  And if you want to be successful at the scrape strategy your script must implement the dynamics of a well-behaved browser, accepting and returning cookies, following headers and redirection, executing JavaScript, etc.  In other words, it's a huge amount of work and it creates a brittle "solution."  The API would seem to be so much easier; that's why web publishers implement APIs.
Avatar of mixteral
mixteral

ASKER

If you think about the cons of getting & using their API, you may pretty well have an idea of what I'm doing and why I do not wish to rely on that :)

If you have some piece of code I could start using for cookie management & other tricky part of this, I'd truly appreciate :)
ASKER CERTIFIED SOLUTION
Avatar of mixteral
mixteral

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have found most of what I was looking for explained in details here :

http://www.barattalo.it/2010/09/09/how-to-change-twitter-status-with-php-and-curl-without-oauth/