To open a regular share dialog like this one:
I use this following code:
FB.ui({
method: 'share',
href: 'https://www.happymood.co',
}, function(response){});
Now if I want the default option to show "On your Friends' Timeline" instead of "On your own Timeline", what changes must I make to this code?
It´s not possible at all to define another default setting. You can check out the Facebook docs to see what parameters you can use: https://developers.facebook.com/docs/sharing/reference/share-dialog
Related
How do i add a hashtag to to Facebook button share...
Please to understand it better click the image
enter image description here
Using the facebook sdk you can add the hashtag parameter to the object.
document.getElementById('share-facebook-btn').onclick = function() {
FB.ui({
method: 'share',
hashtag: '#thisisahashtag'
href: 'https://example.com',
}, function(response){});
}
https://developers.facebook.com/docs/sharing/reference/share-dialog
EDIT:
This answer is outdated, Facebook has since changed their policy (in this specific regard, suggesting a hashtag) - see Andrew's answer for details on the way to do this.
You simply don’t, because you are not allowed to.
See Platform Policy, 2.3:
“Don't prefill captions, comments, messages, or the user message parameter of posts with content a person didn’t create, even if the person can edit or remove the content before sharing.”
If the user wants the message to include a hashtag, then the user has to type it in by him-/herself.
Using Facebook's now deprecated feed dialog, I used to be able to pass in an actions parameter containing a link to an external URL.
For example:
FB.ui({
method: 'feed',
href: 'http://www.example.com',
actions: [{
name: 'Learn More',
link: 'http://www.example.com/learn'
}]
});
I now want to use the share dialog, and am using open graph meta properties to customize the content being shared. I've been reading about the open graph action types, but haven't found anything about how to add an action link to the share dialog that simply links to an external page like the example above does. Does anyone know how I could do this? Thanks!
I am new to facebook API. I've integrated feed dialog successfully. I want to add some CSS to feed dialog. How can I load a FB feed dialog in a DIV tag so that I can add some text above the FB dialog. (For ex: text like share it with your friends... and some instructions)
To display the feed dialog I've used JavaScript SDK. Below is the code...
FB.ui({
method: 'feed',
name: 'Feed dialog',
link: 'http://testmysite.com',
display: 'iframe'
}function(response) {
if (response && response.post_id) {
alert("successful");
});
Any help would be appreciated.
Thanks
Facebook Dialogs are not customizable in this fashion. From Facebook's documentation (emphasis mine):
Dialogs provide a simple, consistent interface to display dialogs to users.
You might want to create your own dialog and use the appropriate Facebook Graph API calls to post to a user's feed.
You cannot style Facebook ui elements, such as the like button share button, ui dialog etc. You can only customize the ui through the parameters Facebook provides you. For the full list of parameters look https://developers.facebook.com/docs/reference/dialogs/feed/. A quick look, and I dont think you can customize the text on the ui dialog.
Hope this helps,
Tyrone
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.
I'd simply like to make an image-click in my FBML page to trigger facebook's ajax dialog box. How do I accomplish this?
I have an FBML tab on my facebook fan page. In the content of that tab, I would like an image to function as a share button.
By following these directions, I can customize a share button, but the image itself that the user clicks on is not customizable. I want to be able to provide my own image, not use the silver share button provided by facebook.
By following these alternative directions I can use my own image. Perfect! Except on thing... Share.php opens as a page instead of as a javascript dialog. So when the user completes the dialog, it closes the whole page!
Here's what it looks like right now. Sorry, you have to click "Like" to see the share image. When you click the image, the share page opens, but I just want the ajax dialog.
I believe you can do what you want using the facebook feed dialogs:
http://developers.facebook.com/docs/reference/dialogs/
this is the javascript that you will have to bind to your onClick event of your link:
FB.ui(
{
method: 'feed',
name: "Name",
link: "http:\\www.facebook.com\pages\#\page_id_here",
picture: "http:\\path\to\image\file.jpg",
caption: "Caption",
description: "Description",
message: "Message"
},
function(response) {
//callback function
}
);