Youtube Data API V3 - Uploading video through PHP code shows error - youtube-api

I've been using following code since a year now but suddenly this errors started appearing.
I'm using PHP Code sample provided in following url
https://developers.google.com/youtube/v3/code_samples/php#upload_a_video
ERROR:
{
"error": {
"errors": [{
"domain": "youtube.thumbnail",
"reason": "videoNotFound",
"message": "The video that you are trying to insert a thumbnail image for cannot be found. Check the value of the requests \u003ccode\u003evideoId\u003c/code\u003e parameter to ensure that it is correct.",
"locationType": "parameter",
"location": "videoId"
}],
"code": 404,
"message": "The video that you are trying to insert a thumbnail image for cannot be found. Check the value of the requests \u003ccode\u003evideoId\u003c/code\u003e parameter to ensure that it is correct."
}
}
I've print statement just before this error catching, and I could see the video ID. And I could see a wiered behavior on my video url.
https://www.youtube.com/watch?v=KV-5aiMDLDg
No comment box, no suggested videos.
Anyone else facing this issue, is there an error/Bug reported recently from Youtube?

I am having the exact same problem. Code has been running fine forever, and now is failing. I added a 20 second delay after the video upload completes, before the thumbnail is set, and it seems to always work now. So it acts like Youtube needs time to digest the video. Would love to hear a better solution though.

Related

Getting a list of all Media in Instagram with Graph API

In my code, I have been pulling the list of media in Instagram using the following URL:
https://graph.facebook.com/{app_id}/media?fields=media_url,{..some fields here...}&limit=10000&access_token={my_access_token}
This was working fine and I didn't touch the code for a month. Now suddenly it gives the error:
{
"error": {
"message": "(#100) Tried accessing nonexisting field (media) on node type (Application)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "Aty4vnPpLWfGq9Hj6hQFtZR"
}
}
Nothing in the documentation says that media is no longer available. Graph API version has updated from v14 to v15 since I used it, but the request isn't working on either version.
Access token is fine because other requests are working correctly.
Does anyone have any insights? What alternatives do I have?
I think you are defining an invalid field. Below is a list of fields you can use. Also i suggest you also try instagram account id instead of app_id.
fields=[id,ig_id,media_product_type,media_type,media_url,thumbnail_url,timestamp,
username,like_count,comments_count]
final url:
https://graph.facebook.com/v14.0/{instagram_account_id}/media?fields=id,ig_id,media_product_type,media_type,media_url,thumbnail_url,timestamp,
username,like_count,comments_count&access_token={my_access_token}

YouTube Data API V3 unkownPart "localizations"

I have been trying to fetch all videos from a playlist using YouTube Data API, which worked like a char; next, I wanted to try and filter videos based on languages, so I wanted to try to include the "localizations" part. However, whenever I do, I get a 400 response stating that "localizations" is "unkownPart". From what I could see in the documentation, I should have my GET request structured properly:
`https://youtube.googleapis.com/youtube/v3/playlistItems?part=localizations&part=snippet&maxResults=${limit}&playlistId=${playlistId}&key=${apiKey}`
Error message in postman:
{
"error": {
"code": 400,
"message": "'localizations'",
"errors": [
{
"message": "'localizations'",
"domain": "youtube.part",
"reason": "unknownPart",
"location": "part",
"locationType": "parameter"
}
]
}
}
"localizations" is a direct copy from the documentation. The GET request works fine if I remove it so I'm confident that the problem is either the order or my parameters, or the combinations of parameters in use (though I couldn't find anything about incompatible parameters in the documentation).
Parameters order goes as follows:
localizations
snippet
playlistId
key
EDIT: link to the documentation: https://developers.google.com/youtube/v3/docs/playlists/list
After sending the Issue Report it was discovered that I had been using the wrong API endpoint. Somehow (I can't remember why) I was using the "playlistItem" endpoint which doesn't support "localizations", and needed to shift to using the "playlists" endpoint instead.
Furthermore when using a combination of both "snippet" and "localization", they should be within the same parameter but comma-separated, however, Postman doesn't auto-convert the commas in the parameters to "%2C" and therefore would cause further trouble understanding the requests. Fixing these 2 steps, it now works as intended.

How can I solve Video Rating Disabled?

I'm doing a project using the YouTube Data API's Videos.rate endpoint.
And I got some problems: some particular minor channels (e.g. my client's channel) are sending error messages:
{
"error": {
"code": 403,
"message": "The owner of the video that you are trying to rate has disabled ratings for that video.",
"errors": [
{
"message": "The owner of the video that you are trying to rate has disabled ratings for that video.",
"domain": "youtube.video",
"reason": "videoRatingDisabled",
"location": "id",
"locationType": "parameter"
}
]
}
My boss wants to help them to solve that problem, but I don't know how to solve this at all. There is no problem with other major channels with 1M+ subscriptions.
I did my best to google this problem, yet couldn't find good results until now.
Before rating the video, check if the vide has enabled the rating.
I can't test right now, but, and idea could be:
Use getRating and check the items[].rating value - if the result is none or unspecified, then, you have to handle your logic for make them know that this video can't be rated - due its owner disabled rating their video.
The message you show in your question says that you cannot rate that video because the owner doesn't allow it. YouTube Data API wont bypass such restriction and there's not much that can be done further.
Ask your boss (or the owner of the video) about allow rating their video(s) and then verify if the video can be rated, if so, try again rate the video.

Making a simple authorized request to eBay

I'm planning to integrate a website with eBay using PHP, but first I'm using Postman to test everything.
Authorization took me an entire day, but I think I've got it working now. (I had to update to the latest version of Postman, then I got it to create a token for me.)
I say I think because I haven't managed to get a single request to work. I deliberately chose bulkGetInventoryItem (documentation) as it seemed like one of the easier authorized requests to get working. I just know that when the authentication settings are wrong, I get a different error message to when they are right.
For troubleshooting reasons, I made a token with all the scopes:
https://api.ebay.com/oauth/api_scope
https://api.ebay.com/oauth/api_scope/sell.marketing
https://api.ebay.com/oauth/api_scope/sell.inventory
https://api.ebay.com/oauth/api_scope/sell.account
https://api.ebay.com/oauth/api_scope/sell.fulfillment
https://api.ebay.com/oauth/api_scope/sell.finances
https://api.ebay.com/oauth/api_scope/sell.payment.dispute
https://api.ebay.com/oauth/api_scope/commerce.identity.readonly
(added as space-separated list of links)
I have changed one of the eBay listings to have an SKU of "123456" just for this test, however the error I get is exactly the same as if I change "sku": "123456" to "sku": "anObviouslyFakeSKU", but anything else I change creates a new error, so I'm suspecting the issue to be SKU related, but maybe it isn't. (I've found the eBay API to be very poor at sending relevant error messages.)
I'm quite new to Postman, so it's likely a rookie mistake.
Earlier errors have shown to be minor punctuation issues or wrong radio buttons ticked, so hopefully whatever the error is this time, it should appear in this screenshot.
What did I do wrong this time? (Let me know if there are any other screenshots I can send that might help.)
To help, both with the post's SEO, and ease of copy/pasting, I am transcribing the important text in the screenshot above:
url
POST https://api.ebay.com/sell/inventory/v1/bulk_get_inventory_item
body, raw
{
"requests": [
{
"sku": "123456"
}
]
}
output
{
"errors": [
{
"errorId": 2003,
"domain": "ACCESS",
"category": "APPLICATION",
"message": "Internal error",
"longMessage": "There was a problem with an eBay internal system or process. Contact eBay developer support for assistance",
"parameters": [
{
"name": "reason",
"value": "Failed to transform underlying error response, see logs."
}
]
}
]
}
Update:
One more screenshot
Update 2:
Another screenshot
A few things you need to check for in Postman.
When you authenticate and receive a token are you posting that token with your api calls like this one POST https://api.ebay.com/sell/inventory/v1/bulk_get_inventory_item?
Have you set the Authorization HTTP header for authentication authorization?
Have you set the Content-Type header for the call to application/json?
More info here: https://developer.ebay.com/api-docs/sell/inventory/resources/inventory_item/methods/bulkGetInventoryItem
Update
Authorization with environment variable in Postman:
Postman environment variables documentation:
https://learning.postman.com/docs/postman/variables-and-environments/variables/
I figured out the issue. My biggest mistake was choosing bulkGetInventoryItem as the "simplest" call. I should have chosen getInventoryItem, as the error reporting on that function is far more user friendly.
So the error I got, for exactly the same request was "We didn't find the entity you are requesting. Please verify the request"
A quick google of the error found me this page https://forums.developer.ebay.com/questions/17883/cannot-get-my-listed-product-by-get-inventory-api.html which led me to the correct answer!
The inventory item I was trying to access was unreachable because it was not created through the developer API.
I hope this answer helps others, as it wasted a full day of my life trying getInventoryItem before tackling bulkGetInventoryItem.

How to update YouTube Channel banner using v3 Data Api?

I'm trying to insert a channel banner using the YouTube v3 Data API. I'm using the .net client library. This documentation calls for a 3 step process.
Upload new banner
Extract new banner url from upload response
Set bannerExternalUrl to extracted url and call channel update.
My problem is with step 2. If I check the returned url is null. I've double check in Fiddler that the json response does not contain a Url property or value.
Anyone have an idea on how do the banner upload? Thanks!
var channelBannerResource = new ChannelBannerResource();
var insertMediaUpload = _serviceV3.ChannelBanners.Insert(channelBannerResource, new FileStream("C:\\banner1.png", FileMode.Open, FileAccess.Read), "image/png");
insertMediaUpload.Oauth_token = _accessToken;
var result = insertMediaUpload.Upload();
//banner Url returns null
var bannerUrl = insertMediaUpload.ResponseBody.Url;
Not too sure but, Check this link out (if you haven't already)
https://developers.google.com/youtube/v3/docs/channelBanners
Your code looks OK on a quick look
One thing to watch out for The image must have a 16:9 aspect ratio and be at least 2120x1192 pixels.
Update
OK, it appears that you haven't called the channels update method. Something like this
Channel updateChannelResponse = youtube.channels()
.update("god knows what parameter(s) here")
Check this link out for more details:
https://developers.google.com/youtube/v3/docs/channels/update
Recon after you call this method the URL should be there...I recon...
Update 2...
Yeah your right, I tried the api explorer but couldn't get that to work either:
https://developers.google.com/apis-explorer/#p/youtube/v3/youtube.channelBanners.insert?_h=2&resource=%257B%250A++%2522url%2522%253A+%2522http%253A%252F%252Ffr.upphotos.net%252Fwp-content%252Fuploads%252F2013%252F05%252FFerrari-HD-Widescreen-Large.jpg%2522%250A%257D&
But unfortunately get an error response, weird thing is it's complaining about the 'part' parameter but there is none...could this be a bug in the API, can't imagine many people using this functionality
{
"error": {
"errors": [
{
"domain": "youtube.part",
"reason": "unexpectedPart",
"message": "contentDetails",
"locationType": "parameter",
"location": "part"
}
],
"code": 400,
"message": "contentDetails"
}
}
I was expecting this insert to give the URL, fresh out of ideas here.

Resources