How to change Facebook send dialog name and thumbnail? - facebook

so I implemented Facebook send dialog in my Facebook app, but the problem is that it always displays server name and some random thumbnail. I put everything as it shown in Facebook documentation but nothing works.
This is my code:
FB.ui({
method: 'send',
name: 'myName',
picture: 'image/path',
link: 'https://apps.facebook.com/APP_ID/',
});

You should read https://developers.facebook.com/docs/sharing/reference/send-dialog according to that page the parameters you can pass in are: app_id, redirect_uri, display, to, link. Neither name or picture are listed.

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

FB.UI Feed Dialog - cannot "share" a facebook's picture

Sharing facebook photo (really a facebook photo) using mobile web app & Feed Dialog.
The problem: Cannot send facebook's photo to the Feed Dialog.
All code works great. I get all properties as they sent to the function.
FB.ui
method: "feed"
link: 'url'
app_id: myAppID
name: 'photo's name'
description: ''
caption: $('#albumName').text()
picture: 'http://myUrl.com/logo.png'
, (response) ->
if response and response.post_id
console.log 'Photo was shared'
else
console.log 'Photo was not shared. Please try again'
If I place a static photo, to represent the Picture parameter, all goes fine, But if I try to call a facebook picture I try to share, then I get a 500 server error.
GET
https://www.facebook.com/dialog/feed?access_token=...662390597_s.jpg&sdk=joey
500 (OK)
This is totally bizarre. The URL that goes to the dialog iframe, goes with all the needed parameters, including access_token.
It seems like a design issue. Like someone in facebook don't want us to pretend to be facebook when we customly share things using their feed dialog, when we share facebook photos.
Am I right?
* Problem Solved. See my answer below *
!!! Problem Solved !!!
Facebook don't accept their own CDN as a source. We need to bypass that in order to share, therefore we can reshare a facebook the photo using a proxy.
http://images.weserv.nl does the job. Facebook accept the image as a picture param, and this way you are able to reshare their posts.
Usage example (plus width and hight to improve performance)
'https://images.weserv.nl/?url=' + facebookImageUrl + '&h=200&w=200'
I can't share facebook photo use this example
when i share with (fb.ui method feed) i get 404 error on this link
https://fbexternal-a.akamaihd.net/app_full_proxy.php?app=460125687444228&v=1&size=z&cksum=047536ba625482c9b5343f2eb94a7039&src=https%3A%2F%2Fimages.weserv.nl%2F%3Furl%3Dhttps%253A%252F%252Ffbcdn-sphotos-b-a.akamaihd.net%252Fhphotos-ak-ash4%252Ft1.0-9%252F10157304_1383818341898181_8685912667835736794_n.jpg%26h%3D200%26w%3D200"
"app=460125687444228
cksum=047536ba625482c9b5343f2eb94a7039
size=z
src=https://images.weserv.nl/?url=https%3A%2F%2Ffbcdn-sphotos-b-a.akamaihd.net%2Fhphotos-ak-ash4%2Ft1.0-9%2F10157304_1383818341898181_8685912667835736794_n.jpg&h=200&w=200
v=1"
Where my error ?

Facebook Send dialog gives 100 error when sending Facebook urls

I'm using the Facebook send dialog to send links to Facebook posts. But I get the following error back from the Facebook API:
API Error Code: 100
API Error Description: Invalid parameter
Error Message: 'link' is invalid.
This is the JavaScript:
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
// assume we are already logged in
FB.init({appId: '569858063028330'});
FB.ui({
method: 'send',
link: 'https://www.facebook.com/benjerryuk/posts/10151500944440101'
});
</script>
You can run it here:
http://jsbin.com/welcome/62834/edit
Facebook send dialog documentation: https://developers.facebook.com/docs/reference/dialogs/send/
I couldn't find it written specifically, but from my attempts it seems that facebook does not accept links to itself for some reason - I can't confirm this, but I got the same result even when I put links of public posts or profiles.
You might have the link refer to your app, which will redirect to the correct facebook post.
Another note: while showing this dialog, facebook loads the given link with AJAX, which means that A) it must be an active URL and B) you cannot use localhost.
Hope that helps.

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.