I'm working right now on uploading youtube videos from a web client to Youtube.
I want to use Javascript to upload video and show the uploaded video before post the url uploaded to my server database.
So the first thing i did is to create an account in Youtube console. and activating Youtube Data Api and then i created an ID clients OAuth 2.0 with the type : Web application and id client has this form : 000000-x1x1x1.apps.googleusercontent.com i have also add an authorized referrer : http://127.0.0.1:3300 since i work in localhost.
So it seems that all is well configured, I've followed the official tutorial youtube gives but when i try to upload a video i had this error :
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid value for: is not a valid value"
}
],
"code": 400,
"message": "Invalid value for: is not a valid value"
}
}
Does any one had this error?
Thanks
I figured it out why i couldn't upload a video the tutorial Youtube gives is not complete Youtube Javascript upload, there is some parameters that i must send and the params i needed are title, description and finally and the most wanted privacyStatus, what i did is adding two text fields with ids #description and #title and fill those text fields with correct data And at last fill the privacyStatus with (private|public) this mean how you want your video to be uploaded.
You can update the upload js file given by Youtube like so :
var metadata = {
snippet: {
title: $('#title').val(),
description: $('#description').text(),
tags: this.tags,
categoryId: this.categoryId
},
status: {
privacyStatus: "public"
}
};
Related
I want to create an ad based on an existing Instagram-Video post. Therefore I already uploaded the video to the /advideos endpoint.
However, now I'm stuck with creating the adcreative. The documentation doesn't give information on how to add the ID of the uploaded video as a parameter to the /adcreative call.
Any suggestions?
This is what my code looks like:
FB.api(
'/act_2757146414569266/adcreatives',
'POST',
{"object_id":"<PAGE_ID>","instagram_user_id":"<IG USER ID>","source_instagram_media_id":"<SRC_MEDIA_ID>","video_data":"{"video_id": "<UPLOADED VIDEO ID>"}"},
function(response) {
...
}
);
This is what I get back:
{
"error": {
"message": "Invalid parameter",
"type": "OAuthException",
"code": 100,
"error_subcode": 1815279,
"is_transient": false,
"error_user_title": "Instagram video must be uploaded to Facebook",
"error_user_msg": "If you want to promote an existing Instagram video, you need to upload it to Facebook first before creating the ad.",
"fbtrace_id": "AfjvS_BshLJ8P3KlAB2EvJg1"
}
}
I'm trying to figure out if a YouTube video is embeddable using the YouTube Data API v3, from answers to similar questions I noticed the status.embeddable property of videos, for a request like this:
https://www.googleapis.com/youtube/v3/videos?id=63flkf3S1bE&part=contentDetails,status&key={MY_API_KEY}
The response is the following
{
"kind": "youtube#videoListResponse",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/ctZQYtBcOuMdnQXh8-Fv1EbS_VA\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/Cd8aGZD09NPuGYNumIEozZs2S90\"",
"id": "63flkf3S1bE",
"contentDetails": {
"duration": "PT8M23S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": false,
"projection": "rectangular"
},
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true,
"madeForKids": false
}
}
]
}
The embeddable parameter under status is returned as true, HOWEVER this video is not actually embeddable, as can be seen here.
When actually embedding the video using the iframe API, there is a more detailed error message as well:
Video unavailable
This video contains content from International Olympic Committee, who has blocked it from display on this website or application.
Watch on YouTube
I don't see how it is possible to detect this case from the YouTube Data API - can anyone help out?
Other option is used in this answer:
Here, you can use the following URL:
https://www.youtube.com/get_video_info?video_id=<VIDEO_ID>
Where VIDEO_ID is the YouTube video_id you want retrieve the information.
In this case, once you get the response, you'll see a property called "playabilityStatus.status".
Here is a extract of the response:
"playabilityStatus": {
"status": "UNPLAYABLE",
"reason": "The video is not available",
"errorScreen": {
"playerErrorMessageRenderer": {
"reason": {
"simpleText": "The video is not available"
},
Additional to johnh10's answer, some of the results saw in the YouTube webpage is not always shown/available in the APIs.
I have the answer. The file that outputs from the https://www.youtube.com/get_video_info?video_id=
is nothing more than a standard text file that is URLENCODED.
To see it properly you first have to DECODE it using a URLDECODER and then you have to separate the json part from the URL querystring part. To take a look at the JSON part you can use a json formatted and to look at the URL part you can use PrettyPrint URL.
Once you do this you will notice that the tag you are looking for to validate weather the video is playable or not is the one mentioned by the other user here. It sits on the URL parameter named "player_response", after you DECODE the file you will find it easily. This parameter holds a longer JSON file that has the playability status under playabilityStatus.Status.
To manipulate it on Javascript simply parse this part of the file as a JSON file and access your node of choice, or parse it as a text and search for the playabilityStatus node that must be unencoded if you dont care to decode it (nothing to fear, only some %2D and %7B instead of spaces and curly brackets).
Good luck!
Unfortunately, this 'copyright check' happens directly from the player. This data is not available through the API.
I'm using again the Facebook Marketing API. I successfully managed to create Facebook ads with my Node.js app, now I want to create ad for Instagram.
To create an AdCreative, my call is as follows:
fb.api('/act_' + rows[0].ad_act + '/adcreatives', 'post', {
"name": "Test Instagram",
"object_story_spec": {
"page_id": "XXXXX",
"instagram_actor_id": "YYYYY",
"link_data": {
"call_to_action": {
"type": "LEARN_MORE",
"value": {
"link": "http://example.com"
}
},
"image_hash": imgHash,
"link": "http://url.com",
"message": "Message test",
"caption": "caption text",
},
}
});
But the API always return the same message:
{ message: '(#100) Param must be a valid Instagram account id',
type: 'OAuthException',
code: 100,
fbtrace_id: 'Dr1XrUANRGr' }
rows[0].ad_act is the right account ID.
XXXX is a valid page id for that ad account.
YYYY is a valid instagram ID that is set as the instagram ads account for the page (setting into FB).
I tried different Instagram accounts as well as pages.
This is the answer :
had to get the instagram_actor_id which is NOT the instagram_account_id.
Graph API : /someFbPageID/instagram_accounts will return instagram account as a graphEdge then get the id of that object, its the instagram_actor_id
"YYYY is a valid instagram ID that is set as the instagram ads account for the page (setting into FB)."
There is not a concept of "Instagram ads account". This YYYY needs to be a valid Instagram account (aka profile) ID. By "valid", I mean:
It cannot be private. It has to be visible to the public. (default is not private.)
It needs to be linked to a Facebook Page or business. https://developers.facebook.com/docs/marketing-api/guides/instagramads/v2.9
If YYYY is linked to a Page, the Page needs to be XXXX.
As you mentioned that "I tried different Instagram accounts as well as pages.", I felt that you are not using a pair of IG and FB accounts. Randomly coupling them won't work.
BTW, the YYYY needs to be a number, which you can find on UI or by calling API in the doc I mentioned above. It cannot be an Instagram handle like "cooldude".
I'm using the FB.api to retrieve users images for my app. According to Facebook Graph API documentation we can obtain user images with:
me/photos // tagged only
me/photos/uploaded // uploaded only
me/photos?type=uploaded // uploaded only
But I would like to retrieve a paginated view of every photo in the user profile. Both uploaded and tagged photos should be returned at once.
I've tried
me/photos/type=uploaded,tagged&limit=25
Which obviously does not work, failing with:
{
"error": {
"message": "(#100) type must be one of the following values: tagged, uploaded",
"type": "OAuthException",
"code": 100
}
}
Is there a way to obtain a complete list of user pictures (including both tagged and uploaded pictures)?
Is it possible using the javascript api to allow a user to post a large photo to their facebook wall? e.g. 500px x 500px, published like a user would normall upload a photo.
All I have been able to achieve so far is small thumbnails.
I currently have the following:
FB.ui(
{
"method": 'feed',
"attachment":
{
"media": [{
"type": "image",
"src": "image.jpg",
"href": "http://www.example.com/"
}]
}
}, function(response) {
if (response && response.post_id) {
//User posted
} else {
//User didn't post
}
}
)
You're posting to the user's feed connection (i.e a wall post) with an image attached - you should use the API to post to their photos directly to upload a photo (see the Graph API Poto documentation)
[edited because this was 'too vague']
You are posting a 'Post' with an image attached, the image in that case is an attachment to the post, it's not rendered in a large size on Facebook.com.
What you probably should be doing is uploading a photo to the user's 'photos' connection like the documentation i linked. There's also a how-to here: https://developers.facebook.com/blog/post/498