2011-09-28 98 views
1

我一直在嘗試使用我自己的代碼在視頻上上傳視頻。 在一步當我嘗試上傳視頻在You Tube元數據以獲取視頻令牌和網址上傳我得到一個獲取POST請求需要內容長度標題響應(411錯誤)

POST請求需要一個Content-Length頭。我們知道的就這些。 (411)

我的代碼如下:

$xml = '<?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">Video.loc</media:title> 
        <media:description type="plain"> 
        Video.loc first vid 
        </media:description> 
        <media:category 
        scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People 
        </media:category> 
        <media:keywords>Video.loc</media:keywords> 
       </media:group> 
       </entry>'; 
    $headers = array('Authorization: AuthSub token="'.$_SESSION['AuthSubSessToken'], 
         'GData-Version: 2', 
        'X-GData-Key: key='.$key, 
        'Content-length:'.strlen($xml), 
        'Content-Type:application/atom+xml; charset=UTF-8' 
       ); 
     $curl = curl_init('http://gdata.youtube.com/action/GetUploadToken'); 

       curl_setopt($curl, CURLOPT_HTTPHEADER,$headers); 
       curl_setopt($curl, CURLOPT_POSTFIELDS, $xml); 
       curl_setopt($curl, CURLOPT_HEADER, 0); 
       $response = simplexml_load_string(curl_exec($curl));         
       $response = curl_exec($curl); 

       $arrToken = explode('=',$response); 
       print('<pre>');print_r($arrToken);die(); 
       curl_close($curl) 

沒有任何一個人都知道,如果它是錯誤在我身邊或在谷歌?

問候 人士Himanshu夏爾馬

+0

請幫助我。這裏讓我難以忘懷。 –

回答

2

你以後

AuthSub token="'.$_SESSION['AuthSubSessToken'], 

可能被搞亂了頭缺少一個右"

相關問題