title: PHP Upload to Youtube, from URL not from form
body: <p>I have downloaded a script to upload videos to YouTube, and it also works perfect.</p>
  
  <p>My question is, what is google's parameters og what is the correctly code to add a video though php only, and not though the form element?</p>
  
  <p>ex.</p>
  
  <pre><code>$videoURL = "Http://myurl.com/video.mp4"; 
  </code></pre>
  
  <p>Here is the code:</p>
  
  <pre><code>&lt;?php session_start();
  set_time_limit(0);
  ini_set('memory_limit', '150M');
  ini_set('upload_max_filesize', '30M');
  ini_set('default_socket_timeout', '6000');
  ini_set('max_input_time', '6000');
  ini_set('post_max_size', '100M');
  ini_set('max_execution_time', '6000');
  
  $accountType = 'HOSTED_OR_GOOGLE';
  $youtube_email    = 'xxxx'; //youtube username or gmail account
  $youtube_password      = 'xxxxx'; //account password
  $source  = urlencode('ps'); //name of application (can be anything) // a short string identifying your application  
  $key  = 'AI39si7OKa6-enYv34I7rm68sVaGHeHAK1fhe6UDx0Qh3Z8DEXr9_SBConY4TJ9HO7mLnZVlVl0xoVGPVEjZPMS6mDmdG0WB9g'; //your youtube developer key
  $authenticationURL= 'https://www.google.com/youtube/accounts/ClientLogin'; 
  
  $postdata = "Email=".$youtube_email."&amp;Passwd=".$youtube_password."&amp;service=youtube&amp;source=$source";
  $curl = curl_init("https://www.google.com/youtube/accounts/ClientLogin");
  curl_setopt($curl, CURLOPT_HEADER, "Content-Type:application/x-www-form-urlencoded");
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
  $response = curl_exec($curl);
  curl_close($curl);
  
  
  list($auth, $youtubeuser) = explode("\n", $response);
  list($authlabel, $authvalue) = array_map("trim", explode("=", $auth));
  list($youtubeuserlabel, $youtubeuservalue) = array_map("trim", explode("=", $youtubeuser));
  
  $youtube_video_title = "sdfsdfdf"; // This is the uploading video title.
  $youtube_video_description = "sdfdfdfdf"; // This is the uploading video description.
  $youtube_video_category = "Film"; // This is the uploading video category.
  $youtube_video_keywords = "devil"; // This is the uploading video keywords.
  
  
  $data = '&lt;?xml version="1.0"?&gt;
          &lt;entry xmlns="http://www.w3.org/2005/Atom"
            xmlns:media="http://search.yahoo.com/mrss/"
            xmlns:yt="http://gdata.youtube.com/schemas/2007"&gt;
            &lt;media:group&gt;
              &lt;media:title type="plain"&gt;'.$youtube_video_title.'&lt;/media:title&gt;
              &lt;media:description type="plain"&gt;'.$youtube_video_description.'&lt;/media:description&gt;
              &lt;media:category
                scheme="http://gdata.youtube.com/schemas/2007/categories.cat"&gt;'.$youtube_video_category.'&lt;/media:category&gt;
              &lt;media:keywords&gt;'.$youtube_video_keywords.'&lt;/media:keywords&gt;
            &lt;/media:group&gt;
          &lt;/entry&gt;';
  
  
  $headers = array("Authorization: GoogleLogin auth=".$authvalue,
               "GData-Version: 2",
               "X-GData-Key: key=".$key,
               "Content-length: ".strlen($data),
               "Content-Type: application/atom+xml; charset=UTF-8");
  
  $curl = curl_init("http://gdata.youtube.com/action/GetUploadToken");
  curl_setopt($curl, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($curl, CURLOPT_TIMEOUT, 10);
  curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($curl, CURLOPT_POST, 1);
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
  curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
  curl_setopt($curl, CURLOPT_REFERER, true);
  curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
  curl_setopt($curl, CURLOPT_HEADER, 0);
  
  $response = simplexml_load_string(curl_exec($curl));
  echo $response;
  curl_close($curl);
  
  
  $rUrl = $response-&gt;url;
  $nexturl = urlencode('http://pointsafari.dk/blablabla.php');
  ?&gt;
  
  &lt;form action="&lt;?php echo $rUrl; ?&gt;?nexturl=&lt;?php echo $nexturl; ?&gt;" method="post" enctype="multipart/form-data" &gt;
    &lt;input id="file" type="file" name="file"/&gt;
    &lt;div id="errMsg" style="display:none;color:red"&gt;
      You need to specify a file.
    &lt;/div&gt;
    &lt;input type="hidden" name="token" value="&lt;?php echo($response-&gt;token); ?&gt;"/&gt;
  
     &lt;input type="submit" value="go" /&gt;
  </code></pre>
  
  <p>Hope someone can help!</p>