मैं यहां बताए अनुसार, एक वीडियो PHP में कर्ल के साथ यूट्यूब एपीआई v3 का उपयोग कर अपलोड होगा: https://developers.google.com/youtube/v3/docs/videos/insertकर्ल और एपीआई v3 का उपयोग कर
मैंने इस समारोह
function uploadVideo($file, $title, $description, $tags, $categoryId, $privacy)
{
$token = getToken(); // Tested function to retrieve the correct AuthToken
$video->snippet['title'] = $title;
$video->snippet['description'] = $description;
$video->snippet['categoryId'] = $categoryId;
$video->snippet['tags'] = $tags; // array
$video->snippet['privacyStatus'] = $privacy;
$res = json_encode($video);
$parms = array(
'part' => 'snippet',
'file' => '@'.$_SERVER['DOCUMENT_ROOT'].'/complete/path/to/'.$file
'video' => $res
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://www.googleapis.com/upload/youtube/v3/videos');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $parms);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer '.$token['access_token']));
$return = json_decode(curl_exec($ch));
curl_close($ch);
return $return;
}
लेकिन यह यह
stdClass Object
(
[error] => stdClass Object
(
[errors] => Array
(
[0] => stdClass Object
(
[domain] => global
[reason] => badContent
[message] => Unsupported content with type: application/octet-stream
)
)
[code] => 400
[message] => Unsupported content with type: application/octet-stream
)
)
फ़ाइल एक एमपी 4 है।
कोई भी मदद कर सकता है?
धन्यवाद! मेरा प्रयास कुछ हल्का बनाना था, लेकिन मैं आधिकारिक Google लाइब्रेरी – genna
को Google_YoutubeService.php में आज़माउंगा, मुझे उस सम्मिलित विधि को कॉल करने के लिए कोई फ़ंक्शन नहीं मिल रहा है जिसकी मुझे आवश्यकता है। सभी विधियां लिस्टिंग के लिए हैं (चैनल, प्लेलिस्ट, वीडियो ..) मुझे लाइब्रेरी के एक नए संस्करण की प्रतीक्षा करनी है? – genna
मैंने – genna