I know this question is duplcated, but the phenomena is different.
I use Youtube API PHP to upload my videos. Unfortunately, its caught errors:
{
"status": "fail",
"mess": "Failed to start the resumable upload (HTTP 400: youtube.video, The request metadata specifies an invalid video description.)"
}
I checked the description. Use mb_strlen()
return result less than 5000 characters.
$title = mb_substr($title, 0, 100);
$description = mb_substr($description , 0, 4999);
$tags = array_slice($tags, 0, 15);
$snippet = new Google_Service_YouTube_VideoSnippet();
$snippet->setTitle($title);
$snippet->setDescription($description);
$snippet->setTags($tags);
$snippet->setCategoryId("22");
$status = new Google_Service_YouTube_VideoStatus();
$status->privacyStatus = "public";
$video = new Google_Service_YouTube_Video();
$video->setSnippet($snippet);
$video->setStatus($status);
Have some special characters exist: <>
, |
, '
(single qoute), ()
, ?
, "
(double quote).
I researched about this error, but not any results :(
Your API key may not be working because you're using it for the wrong project. Be sure you're using the key for the project that you created it for, especially if you created multiple projects at the same time. If it's still not working, consider creating a new API key entirely.
Core API errorsAccess forbidden. The request may not be properly authorized. quotaExceeded (403) quotaExceeded. The request cannot be completed because you have exceeded your quota.
After creating your project, make sure the YouTube Data API is one of the services that your application is registered to use: Go to the API Console and select the project that you just registered. Visit the Enabled APIs page. In the list of APIs, make sure the status is ON for the YouTube Data API v3.
You need to remove all <
>
characters from your description.
$description = str_replace(['>', '<'], '', $description);
$snippet->setDescription($description);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With