I'm using a Facebook feed dialog through JavaScript:
var p = {
method: 'feed',
name: 'Title',
caption: 'Subtitle - 26/02/2013',
description: 'My text',
link: window.location.href
};
FB.ui(p)
Is there a way to allow the user select the destination page for the feed ?
Usually the resulting dialog allows user to post a message on his own wall. I would like to enable destination select, like:
on my wall or on my page or into a group
With subsequent page or group selection, as happens on Facebook site.
Is there a way to show this kind of selection ?
The built-in share dialog included in the JavaScript SDK doesn't include this functionality. You will instead need to create your own dropdown with the options you want and then have the share button underneath. You will then need to find the value of this dropdown and add it to the to parameter of the FB.ui function:
<select id="to_user">
<option value="{user_id}">My wall</option>
<option value="{page_id}">My page</option>
<option value="{group_id}">My group</option>
</select>
<script>
var p = {
method: 'feed',
to: $('#to_user').val(),
name: 'Title',
caption: 'Subtitle - 26/02/2013',
description: 'My text',
link: window.location.href
};
FB.ui(p);
</script>
There is an option in the feed dialog box for selecting the destination.Please check
http://developers.facebook.com/docs/reference/dialogs/feed/
Related
I am trying to send this to facebook and it works except for the title "Some Page Title" is not showing up in the post. Example
The format i am using:
https://www.facebook.com/sharer/sharer.php?u=<url>&t=<page title>
Is passing title not supported any more?
TIA
To overwrite Open Graph meta tags you're only chance is with feed method which requires an app id
JS
$('#facebook-share').click(function (e) {
e.preventDefault();
FB.ui({
method: 'feed', // feed method!
name: 'My title', // overwrites "og:title"
link: 'https://www.facebook.com/Retrogram', // required param
picture: 'http://i.imgur.com/SKwsQM2.png?1', // overwrites "og:image"
caption: 'My caption', // overwrite caption
description: 'My description' // overwrites "og:description"
});
});
Fiddle
I'm having product listing page . I would like to show share link for each product and i want to share individual product image . How can i do this ?
I believe meta doesn't help, because i need to share individual product image.
Create your own button for each image, an onclick invoke FB.UI from the JS SDK https://developers.facebook.com/docs/reference/javascript/FB.ui/ passing in the variables you want for the message
So for each image the html could like similar to:
<img src="path-to-image" title="title" data-uri="path-to-full-product" />
Then using a library like jquery you could have the following script
$('img').click(function(){
var $this = $(this);
var obj = {
method: 'feed',
link: $this.data('uri'),
picture: $this.attr('src'),
name: $this.attr('title'),
caption: 'Your caption here',
description: 'Your description here.'
};
function callback(response) {
alert( "Post ID: " + response['post_id']);
}
FB.ui(obj,callback);
});
More info with an example is here:
https://developers.facebook.com/docs/reference/dialogs/feed/
and you can play around with the JS-SDK here
https://developers.facebook.com/tools/console/
I am having trouble getting code correct to have user (of my app) post to friend's wall. I want user to be able to pick single friend and post to thier stream. What am I missing to have the user select 1 friend from list, or type friends name? This is my "post" function that I can't get to work. It works when the method is 'feed' to post to the user's wall. But method as 'stream.publish' it still functions like 'feed' and posts to user's wall.
function pubStream(obj,gift_id,item_name)
{
FB.ui({
method: 'stream.publish',
display: 'popup', //have tried display:iframe does same
name: "Special Delivery!",
link: "<?php echo $app_info['transfer_protocol']; ?>apps.facebook.com/<?php echo $app_info['canvas']; ?>/?friendID="+facebook_id+"&giftID="+gift_id,
picture: "<?php echo $app_info['upload_url']; ?>"+obj,
caption: "//not used at this time ",
description: "my item escription",
message: "user's message ",
actions: {"name":"my items name","link":"<?php echo $app_info['transfer_protocol']; ?>apps.facebook.com/<?php echo $app_info['canvas']; ?>/?friendID="+facebook_id+"&giftID="+gift_id}
},function(response){hideLightbox();});
}
It looks like you're looking for the 'send' User Interface.
There are docs on this here:
https://developers.facebook.com/docs/reference/dialogs/send/
It's practically the same code as your feed dialog, except the user can specify which friends they want to communicate it to.
Assuming your code is correct this would work:
function pubStream(obj,gift_id,item_name)
{
FB.ui({
method: 'send',
display: 'popup', //have tried display:iframe does same
name: "Special Delivery!",
link: "<?php echo $app_info['transfer_protocol']; ?>apps.facebook.com/<?php echo $app_info['canvas']; ?>/?friendID="+facebook_id+"&giftID="+gift_id,
picture: "<?php echo $app_info['upload_url']; ?>"+obj,
caption: "//not used at this time ",
description: "my item escription",
message: "user's message ",
actions: {"name":"my items name","link":"<?php echo $app_info['transfer_protocol']; ?>apps.facebook.com/<?php echo $app_info['canvas']; ?>/?friendID="+facebook_id+"&giftID="+gift_id}
},function(response){hideLightbox();});
}
You just choose method: 'send' and then use the properties shown on the 'feed' documentation, here: http://developers.facebook.com/docs/reference/dialogs/feed/
I trying to bulid a facebook application using javascript.In my application, the user gets the result and a dialog after a time delay popup. Everthing is working well except one here's my code for the 'post to wall dialog'
<script>
var publish = {
method: 'stream.publish',
display: 'popup', // force popup mode
attachment: {
name: 'Connect',
caption: 'The Facebook Connect JavaScript SDK',
actions: [{ name: 'action_links text!', link: 'http://www.example.com' }],
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
href: 'http://www.example.com/'
}
};
FB.ui(publish, Log.info.bind('stream.publish callback'));
</script>
The line containing actions not working for me.Can anyone just inform what is the solution for this...
The property should be called action_links not actions and only have text and href values. Use something like:
action_links: [{ text: 'action link test', href: 'http://example.com'}]
Note that the action must be defined through the fb web interface for the app!
I want have feed dialog in which i also want to use his First name or user object.I'm using FB.Ui method.
<script>
var publish = {
method: 'stream.publish',
display: 'popup', // force popup mode
attachment: {
name: 'I visted this Appp',
caption: 'The Facebook Connect JavaScript SDK',
description: (
'A small JavaScript library that allows you to harness ' +
'the power of Facebook, bringing the user\'s identity, ' +
'social graph and distribution power to your site.'
),
href: 'http://fbrell.com/'
}
};
FB.ui(publish, Log.info.bind('stream.publish callback'));
</script>
As you can see in caption it is ' i visited this app'.I want to change it to the Facebook user's first name..i.e 'first_name visted this app'..Anyone can help me out
To get info about the user, you would first need to have them authenticate with your application (no extended permissions would be needed as name is considered "basic" information). Then you could then call a FQL query with the javascript api to get their name and then use that to populate the message.
Authenticate user:
<fb:login-button autologoutlink="true"></fb:login-button>
Get users name:
FB.api(
{
method: 'fql.query',
query: 'SELECT name FROM user WHERE uid='+FB.getSession().uid
},
function(response) {
alert(response[0].name);
}
);