1

これは私が使用している関数です:

function uploadVideo($file, $title, $description, $tags, $categoryId, $privacy, $tokenacc){
$direccionvideo = $_SERVER['DOCUMENT_ROOT'].'/uploadyt/mp4/'.$file;
$video->snippet['title']         = $title;
$video->snippet['description']   = $description;
$video->snippet['categoryId']   = $categoryId;
$video->snippet['tags']       = array($tags); // array

$video->status['privacyStatus'] = $privacy;

$res = json_encode($video);

$parms = array(
'part'  => 'snippet, status',
    'file'  => '@'.$direccionvideo,
    'body' => $res
);

$cabeceras = array('Authorization: Bearer '.$tokenacc, 'Content-Type: video/mp4');

$ch = curl_init('https://www.googleapis.com/upload/youtube/v3/videos?part=snippet,status&key=AIXXXXXXXXXXXXXXXXX');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parms);
curl_setopt($ch, CURLOPT_HTTPHEADER, $cabeceras);
$return = curl_exec($ch);
curl_close($ch);

return $return;
}

しかし、それはこれを返します:

{ "kind": "youtube#video", "etag": "\"rFqCJSkEICLP3Hq6a4AADI7kf48/Ppz1_LDXz9KAv4eC-UouSKrhjn4\"", "id": "XXXXXXXXX", "snippet": { "publishedAt": "2013-07-15T03:06:45.000Z", "channelId": "UCWXN1EzwIl2clMliTxxO7ww", **"title": "unknown"**, **"description": ""**, "thumbnails": { "default": { "url": "https://i1.ytimg.com/vi/XXXXXXXX/default.jpg" }, "medium": { "url": "https://i1.ytimg.com/vi/XXXXXXXX/mqdefault.jpg" }, "high": { "url": "https://i1.ytimg.com/vi/XXXXXXXX/hqdefault.jpg" } }, "channelTitle": "ChannelYouTube", "categoryId": "2" }, "status": { "uploadStatus": "uploaded", "privacyStatus": "public", "license": "youtube", "embeddable": true, "publicStatsViewable": true } }

タイトルが「不明」で、説明、タグ、カテゴリのないビデオ (処理できない) をアップロードします。

これは、API が投稿フィールドを取らないかのようです。

誰でも助けることができますか?

4

0 に答える 0