Mam taki kod:
<?php $youtube_email = "nazwa@gmail.com"; $youtube_password = "xxx"; $postdata = "Email=".$youtube_email."&Passwd=".$youtube_password."&service=youtube&source=Example"; $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); $youtube_video_title = "Example"; // This is the uploading video title. $youtube_video_description = "test"; // This is the uploading video description. $youtube_video_category = "News"; // This is the uploading video category. $youtube_video_keywords = "example, video"; // This is the uploading video keywords. $data = '<?xml version="1.0"?> <entry xmlns="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"> <media:group> <media:title type="plain">'.$youtube_video_title.'</media:title> <media:description type="plain">'.$youtube_video_description.'</media:description> <media:category scheme="http://gdata.youtube.com/schemas/2007/categories.cat">'.$youtube_video_category.'</media:category> <media:keywords>'.$youtube_video_keywords.'</media:keywords> </media:group> </entry>'; $key = "AI3...X7A"; // Generated KEY here: <a href="http://code.google.com/apis/youtube/dashboard/" target="_blank">http://code.google.com/apis/youtube/dashboard/</a>. "GData-Version: 2", "X-GData-Key: key=".$key, "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)); curl_close($curl); ?> <script type="text/javascript"> function checkForFile() { if (document.getElementById('file').value) { return true; } document.getElementById('errMsg').style.display = ''; return false; } </script> <?php $nexturl = "http://www.domena.pl"; // This parameter specifies the URL to which YouTube will redirect the user's browser when the user uploads his video file. ?> <input id="file" type="file" name="file"/> <div id="errMsg" style="display:none;color:red"> You need to specify a file. </div> <input type="submit" value="go" /> </form> </php>
Kiedy usuwam formularz i chcę dodać nowy field np:
curl_setopt($curl, CURLOPT_POSTFIELDS, $plik_video);
to pojawia mi się błąd w
$response = simplexml_load_string(curl_exec($curl));
jak zrobić zainicjowanie wysyłania po odświerzeniu linku ze skryptem. Próbowałem kilku rozwiązań ale coś mi nie idzie . Instrukcja API dla Youtube w php jest napisana pod klasę dla zend , tam jest użyte 'setSlug' ale to jest odniesienie do tej klasy.
https://developers.google.com/youtube/2.0/d...ploading_Videos
Dzięki z góry
dodałęm jeszcze :
<media:content url="videofile.3gp" fileSize="5319922" type="video" height="270" width="480"></media:content>
i otrzymuję to:
string(549) "http://uploads.gdata.youtube.com/action/FormDataUpload/AIwbFAT....
ale po wpisaniu tego linku nie wysyła:
otrzymuję:
HTTP method GET is not supported by this URL
Error 405
Co może być nie tak, chcę po prostu wysłać wszystkie dane z plikiem do youtube , bez użycia formularza za pomocą curl_setopt.
Gdzie robię błąd?
Dzięki z góry