Facebook Like HTML5 Canvas - facebook

Does anyone know if a user generated HTML5 Canvas could be attached to a Facebook 'Like' action and shared on a Facebook wall?
I guess the canvas would have to be rendered to an <img> tag and the id of the tag specified in the og:image metadata?

You have two options as I see it.
(1) Use the Like Button and in it put a dynamic url which generates the og tags for the configuration the user has chosen.
In the 2nd step of the like button tutorial it generates the og tags for you so you can see what's needed, then just make sure that your server generates those according to what the user configured.
You'll have to make a request from your page to the server when the user finished his configuration so that this will be possible.
(2) Use the Feed Dialog that comes with the js sdk.
Using that you can specify all of the story fields, for example:
var obj = {
method: "feed",
picture: "URL_FOR_THE_CONFIGURED_BIKES_PIC",
name: "My custom bikes!",
caption: "I just finished building a new pair of bikes",
description: "My configuration: ....."
};
FB.ui(obj, function(response) {
console.log(response);
});
It is of course possible to mix both options into a third, if you have a specific url per configuration then you can simply:
FB.ui({
method: "feed",
link: "URL_FOR_THE_USER_CONFIGURATION"
}, function(response) {
console.log(response);
});
And then facebook will extract the data from the og tags in that link.

Related

Using the FB API, can you share a link, but serve an image that is not on the page

I can post a photo IF I had the time to get an app approved. I can share a link that pulls in a photo from THAT page. The goal is to post a link that goes to X, but the image is hosted somewhere else.
Is this possible?
Yes, it's possible by using the JavaScript SDK and the Share Dialog. For example, I can do the following, which shares a link but with a custom image, name and caption. It basically overwrites all the OG data on my page.
function fb_share() {
FB.ui( {
method: 'feed',
name: "Facebook API: Tracking Shares using the JavaScript SDK",
link: "https://www.webniraj.com/2013/05/11/facebook-api-tracking-shares-using-the-javascript-sdk/",
picture: "https://stackexchange.com/users/flair/557969.png",
caption: "Tracking Facebook Shares on your website or application is a useful way of seeing how popular your articles are with your readers. In order to tracking Shares, you must used the Facebook JavaScript SDK."
}, function( response ) {
// do nothing
} );
}
$(document).ready(function(){
$('button.share-btn').on( 'click', fb_share );
});
You can do the same thing in PHP if you have the publish_actions permission approved by Facebook. Both would produce the following result:
Source

Make Facebook share button works in iframe and share parent page URL with iframe meta tags

I am working on the embeddable quiz widget. Let's say we have page with quiz iFrame http://page.com/quiz, iframe src is http://quizes.com/quizes/1. I use this JS code to init Facebook share button:
FB.ui({
method: 'share',
href: 'http://quizes.com/quizes/1?result_id=2'
});
At http://quizes.com/quizes/1?result_id=2 we render og:title, og:description and og:image based on user result. The thing is that if quiz is embedded in Facebook post I want to see parent domain (page.com) but it is quizes.com (gistroll.com– real project domain).
I tried to pass parent page url to share link like this: http://quizes.com/quizes/1?result_id=2&url=http://page.com/quiz and use url in og:url, but Facebook Crawler follows http://page.com/quiz in this case and of course there are wrong og meta tags there.
Question: Any ideas how fix that and show different domain in Facebook feed? (May be we can pass all necessary params with JS?)

Facebook Feed Dialog Parameters vs. Open Graph Meta Tags

Do the Open Graph meta tags override the corresponding parameter values passed in FB.ui?
I have a page where I have an og:description tag (I want it to be used by the like button). I have a share button which triggers a share dialog using FB.ui.
Coffeescript Code:
FB.ui({
method: 'feed',
link: Selfstarter.baseUrl(),
caption: caption,
name: 'Healthfundit',
description: 'Some Description',
actions: [{name:'Help Fund It!', link: Selfstarter.baseUrl() + "/preorder/checkout" }]
source: source
}, (response) ->);
When I test the share button, the description that is displayed is the one I specified in the og:description tag.
Do the Open Graph meta tags override the corresponding parameter values passed in FB.ui?
No, the other way around.
If that’s not working for you, then most likely there’s an error in your code. [As we figured out, that was it.]

FB.ui dialog (iframe) is invisible

i am trying to add the stream.publish functionality to my web app, but i'm having a problem with the 'feed' dialog.
My code is the following:
var obj = {
method: 'feed',
display: 'iframe',
name: data.name,
link: data.link,
picture: data.picture,
caption: data.name,
description: data.description,
message: data.message,
actions: [{
name: data.actions.name,
link: data.actions.link
}],
user_message_prompt: ''
}
var resp = FB.ui(obj, function(response) {
alert("DONE");
});
I can make it work if i use 'popup' instead of 'iframe' but that's not what i want.
Any ideas why the feed is just not appearing in my screen???
Thanks!
As described in Dialogs documentation
If you specify iframe, you must have a valid access_token. To get a valid access_token, please see the Authentication guide
Update:
Seems there is couple of other statements that may lead to this behaviour:
iframe: Display the dialog in a lightbox iframe on the current page. Because of the risk of clickjacking, this is only allowed for some certain dialogs, and requires you to pass a valid access_token.
And this one.
On Facebook canvas pages, Dialogs are supported only for iframe applications
There is also open BUG #246637628719849 about "Send Dialog" not working with as iframe in Page Tabs (which may, or may not be related).
Update2:
Actually in all my applications I've user FB.ui without specifying display since at the time of implementation of Dialogs iframe wasn't working well in most cases, and without it Facebook JS-SDK trying to use most appropriate display mode...
Update3:
OP had fb-root within other DOM element which was hidden, causing Dialog to be invisible (as he stated in comment)

Why does facebook change the link in the FB.ui send dialog?

I'm creating a facebook dialog here that links to an external site (not from my domain). In the preview the link shows up correctly, but when the message is viewed in the inbox the url has been changed.
Specifically, I call this function:
var link = "http://someexternalsite.com/?id=xxx"
var desc = "a description"
FB.ui(
{
method: 'send',
name: 'title',
link: link,
picture: 'http://mysite.com/somepicture.jpg',
description: desc
},
function(response) {}
)
And the link changes (when viewed in your facebook inbox) to
http://facebook.com/someexternalsite
Is there some unwritten security policy somewhere? Do I need to get permission from someexternalsite.com to link to their site?
Facebook keeps control of the links that are posted. That way if a link is to a virus or a malicious site, Facebook just needs to change their URL.
It seems that facebook take the meta og: property.
I didn't find a way to get the link I wanted without changing the og:url.
Btw the picture is also erase by the og:image tag.