Hello. I'm quite a newbie to cURL and php. I have been trying hard to login at youtube using cURL but haven't had any success.

All i get in return when i run the following code is the youtube login page, with my username(which i used in the code) written at the username Field and it doesn't login.

Can anyone tell me what's goin on ? :)

<?php

$posturl  = '&GALX=obiRBhLUBIa&Email=myfancyusername@gmail.com&Passwd=myfancypassword&rmShown=1&signIn=Sign+in&asts=';

$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookieYoutube");
curl_setopt($ch, CURLOPT_URL,"https://www.google.com/accounts/ServiceLogin?service=youtube");
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); 
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: application/x-www-form-urlencoded"));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookieYoutube");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt($ch, CURLOPT_REFERER,"https://www.google.com/accounts/ServiceLogin?service=youtube");
curl_setopt($ch, CURLOPT_POSTFIELDS, $posturl);


$output = curl_exec ($ch); 

curl_close($ch);

echo $output;

?>

can someone at least tell me if it's possible or not ?

I have made an app to login to youtube in VB and it worked fine.

Instead of ServiceLogin, use ServiceLoginAuth

should work. Could you come to expertcore org to discuss on this?

can someone at least tell me if it's possible or not ?

You should be able to if you send the right HTTP request. Since the login page is under HTTPS, observing the HTTP request is not straight forward.

What are you using to look at the HTTP request, if any? Or are you just creating the request based on the login form?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.