Well I have a curl script which I have edited from a sample script so it should be working, but when I echo the output it simply gives "1" on the screen. Why?
How do I get it to echo the output of the page that it finally gets to? Anyway, here is my script. You can try it out if you want, just replace PASSWORD and USERNAME with your youtube password and username.
<?php
/*
This script is an example of using curl in php to log into on one page and
then get another page passing all cookies from the first page along with you.
If this script was a bit more advanced it might trick the server into
thinking its netscape and even pass a fake referer, yo look like it surfed
from a local page.
*/
$ch = curl_init();
curl_setopt($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_URL,"http://www.youtube.com/login");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "/login current_form=loginForm&username=Keepyourvideos&password=Keepyourvideos&action_login=Log+In");
ob_start(); // prevent any output
curl_exec ($ch); // execute the curl command
ob_end_clean(); // stop preventing output
curl_close ($ch);
unset($ch);
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt($ch, CURLOPT_URL,"http://www.youtube.com/watch?v=XcHyY9poq4w");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); //Not sure about this... I added it myself
$buf2 = curl_exec ($ch);
curl_close ($ch);
echo "<PRE>".htmlentities($buf2);
?>