Web Hosting Talk







View Full Version : PHP cURL expert please enter


lonea
08-26-2009, 04:09 AM
I'm trying to write a script that logs into youtube via cURL, but I'm getting nowhere.

Problem one- I'm not sure which website URL I should use. The actual login page or the the URL that is being called when the form is submitted.

So in this case,


https://www.google.com/accounts/ServiceLogin?uilel=3&service=youtube&passive=true&continue=http%3A%2F%2Fwww.youtube.com%2Fsignin%3Faction_handle_signin%3Dtrue%26nomobiletemp%3D1%26hl%3Den_US%26next%3D%252F&hl=en_US&ltmpl=sso

or

https://www.google.com/accounts/ServiceLoginAuth?service=youtube

Problme two- Is this how I set the POST vars ?

curl_setopt($ch, CURLOPT_POSTFIELDS, "username=username&password=pw);

Thanks.

ramnet
08-26-2009, 10:18 PM
Problem one- I'm not sure which website URL I should use. The actual login page or the the URL that is being called when the form is submitted.


You'll need to use the URL that the login form submits it's information to - not the login page itself (you look at that page to get the values to submit and where to submit them too).

(disclaimer: not a cURL expert, but I know how html forms work)

since you are using php you might want to look at fsockopen - it might be easier to do what you want with that since it's more low-level than cURL (you can capture the traffic between your browser and youtube/google with firefox and "live http headers" addon and easily adapt it to work over a raw fsockopen connection).

mattle
08-26-2009, 11:32 PM
Sounds like a job for Perl...many modules dedicated to this type of task.

cselzer
08-26-2009, 11:34 PM
Take a look at http://www.ngcoders.com/php/php-youtube-video-downloader-script

and dissect that code.. it will get you logged in..

I have a code at home (currently at a relatives house) for it.. but i do know this will work.. same concept.