How to user PHP cUrl to login to a Twitter oAuth site?
Posted: Sun Apr 11, 2010 12:12 pm
Hi,
I am trying to use php cUrl to execute a php file on a website that requires login using Twitter oAuth. Some of may be familiar with this service. The website generates a oauth token and sends it to Twitter, who then ask you to allow the application. When you do you are then sent to the applications callback.php with the token being sent again. This then gives you a cookie called PHPSESSID that keeps you logged in. I am having some trouble with this though. In order to get the cookie with cUrl I have to do the rest. I have started by loading the main page of the site into a DOM object and extracting the Twitter oauth url. I then curl to that url but cannot work out how to parse the login details. The form on that page has the action set to that page and I have tried manually creating a url using that and all the inputs in the form but I just end up back there. So how can I do this???
I am sure there are a reasonable number of situations where this could be useful. Maybe someone has done it already? If not it would be good to know anyway. Thanks for any help,
Sam.
ps. Please tell me if you need any code posted.
I am trying to use php cUrl to execute a php file on a website that requires login using Twitter oAuth. Some of may be familiar with this service. The website generates a oauth token and sends it to Twitter, who then ask you to allow the application. When you do you are then sent to the applications callback.php with the token being sent again. This then gives you a cookie called PHPSESSID that keeps you logged in. I am having some trouble with this though. In order to get the cookie with cUrl I have to do the rest. I have started by loading the main page of the site into a DOM object and extracting the Twitter oauth url. I then curl to that url but cannot work out how to parse the login details. The form on that page has the action set to that page and I have tried manually creating a url using that and all the inputs in the form but I just end up back there. So how can I do this???
I am sure there are a reasonable number of situations where this could be useful. Maybe someone has done it already? If not it would be good to know anyway. Thanks for any help,
Sam.
ps. Please tell me if you need any code posted.