2014-05-10 79 views
1

我嘗試用圖形API此處上傳在Dailymotion視頻:錯誤試圖上傳Dailymotion上的視頻與圖形API時

http://www.dailymotion.com/doc/api/graph-api.html

與讀取成功驗證和寫入權限,但嘗試使用上傳視頻時下面API發佈方法:http://www.dailymotion.com/doc/api/graph-api.html#publishing得到錯誤

stdClass的對象([出錯] => stdClass的對象([代碼] => 400 [消息] =>的`URL」參數返回一個無效的內容類型:text/plain的,必須是視頻/ * [類型] => INVALID_PARAMETER))

我使用下面捲曲發佈請求API:

$fields = ''; 
    $data = array(
     "access_token" => $token, 
     "url" => "https://www.somesite.com/demo/dailymotion/X.mp4" 
    ); 
    $url = "https://api.dailymotion.com/me/videos"; 
    foreach($data as $key => $value) { 
     $fields .= $key . '=' . $value . '&'; 
    } 
    rtrim($fields, '&'); 

    $post = curl_init(); 

    curl_setopt($post, CURLOPT_URL, $url); 
    curl_setopt($post, CURLOPT_POST, count($data)); 
    curl_setopt($post, CURLOPT_POSTFIELDS, $fields); 
    curl_setopt($post, CURLOPT_RETURNTRANSFER, 1); 

    $result = curl_exec($post); 

    curl_close($post); 
    print_r(json_decode($result)); 

有人請幫我解決這個問題。

回答

1

我覺得你有與URL到您的視頻問題,它看起來像它不會被識別爲視頻:

invalid content type: text/plain, must be video/* [type] 

您應該使用通過API提供一個上傳網址:執行HTTP GET來/ file/upload以獲取上傳URL並使用文件字段中的視頻的多部分/表單數據內容類型將視頻發佈到此地址。當用這個URL測試你的代碼時,它工作。

雖然我有兩條評論:爲什麼不使用php sdk?它將使您的一切變得更加輕鬆!此外,爲了讓您的視頻被髮布,應指定一個標題和它的信道,並設置「發表」爲真,在你的數據數組:http://www.dailymotion.com/doc/api/getting-started.html#publishing-videos 和:

$data = array(
    "access_token" => $token, 
    "channel" => "news", 
    "title" => "my title", 
    "published"=> True, 
    "url" => $videourl 
); 

這在描述你可以找到一個用例使用php sdk在http://www.dailymotion.com/doc/api/use-cases.html