Is it possible to publish a large photo to facebook? - javascript

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

Related

Facebook Marketing API: create Adcreative with Instagram Video

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"
}
}

Posting equirectangular 360° panoramas on Facebook using Javascript Graph API

I am trying to post 360° photos on behalf of my app's users, but I can't figure out how to make it work.
I loaded the Facebook Javascript Graph API, logged the user with "publish_actions" scope and used the following code to post a picture using equirectangular projection:
FB.api(
"/me/photos",
"POST",
{
"url": "MY_PUBLIC_URL",
"allow_spherical_photo": true,
"spherical_metadata": {
"ProjectionType": "equirectangular",
"CroppedAreaImageWidthPixels": 240,
"CroppedAreaImageHeightPixels": 240,
"FullPanoWidthPixels": 1962,
"FullPanoHeightPixels": 981,
"CroppedAreaLeftPixels": 981,
"CroppedAreaTopPixels": 490
}
}, function (response) {
console.log(response); // I get "{"id":"...", post_id:"..."} so no error
if (response && !response.error) {
/* handle the result */
}
}
);
It is posting correctly on the current user's timeline, but it is shown as a "normal" picture, not a 360° panorama.
Did someone implement a 360° panorama posting feature that works?
My photo should have the correct ratio (2:1) and is a correct 360° photo.
Thank you in advance for your help.
I finally found a working solution for my issue: only put "allow_spherical_photo": true and remove spherical_metadata.
Then, the 360° pictures need to have metadata on them, in order for the Facebook processing to display them properly (XMP metadata as explained here: https://developers.google.com/streetview/spherical-metadata)
Thanks.

Facebook marketing API : Param must be a valid Instagram account id

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".

Youtube Data API V3 Javascript

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"
}
};

Retrieve uploaded and tagged photos at once

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)?

Categories

Resources