Assuming the code below, which works correctly (IE: when the user presses the share button, the content is published to THEIR page), how would I also get it to publish to the Apps page also, ideally changing the message slightly. At the moment the text posted to the users wall is, for example, "I like xx on xx website". I would also like the event posting to my App page, with a different message along the lines of " just liked xxx on our website".
Just to clarify, this code works OK, but I would like to publish to my Apps page at the same time with a different message.
Thanks in advance.
<input type="button" onclick="share_prompt()" value="Share" />
<script src="http://connect.facebook.net/en_US/all.js" type="text/javascript" charset="utf-8"></script>
<div id="fb-root"></div>
<script type="text/javascript" charset="utf-8">
FB.init({
appId: 'YOUR_APP_ID',
status: true,
cookie: true,
xfbml: true
});
function share_prompt()
{
FB.ui(
{
method: 'feed',
name: 'Facebook Dialogs',
link: 'http://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
message: 'Facebook Dialogs are easy!'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
</script>
Related
I am using "fb.ui share dialog" to share video from app to my wall, resulting not embedding on friends news feed, message is showing but no video.
Where as i can see video embed on my profile page, with message. All working fine but not on friends wall.
See screenshot
Code
FB.ui(
{
method: 'feed',
name: 'Lorem ispm',
link: 'google.com',
picture: 'http://img.youtube.com/vi/'+ getParameter(addressValue, 'v') +'/0.jpg',
caption: 'Hello',
source: 'http://www.youtube.com/v/'+ getParameter(addressValue, 'v') +'?version=3&autohide=1&autoplay=1',
type: 'video',
description: 'Hello'
},
function(response) {
if (response && response.post_id) {
//alert('Post was published.');
} else {
//alert('Post was not published.');
}
}
);
Just use the link parameter as the youtube video url. You dont need to use image and other parameters.
FB.ui(
{
method: 'feed',
name: 'Lorem ispm',
caption: 'Hello',
link: 'http://www.youtube.com/watch?v='+ getParameter(addressValue, 'v'),
description: 'Hello'
},
function(response) {
if (response && response.post_id) {
//alert('Post was published.');
} else {
//alert('Post was not published.');
}
}
);
Example
Youtube has their og tags defined on their page. It will provide facebook with the related image and other things.
Another thing to note is that- you must use Share Dialog now instead, the feed dialogs are deprecated.
FB.ui({
method: 'feed',
name: 'Help set the record straight!',
link: 'http://www.facebook.com/nothingbeatsbeef/app_545512565475443',
picture: 'http://cs.apps2.pixolut.com/rsrc/509309abe46cea93eefec36a',
caption: '',
description: 'No longer will Aussies be taunted with ‘Throw another shrimp on the barbie’. Sign the petition to get the ad that started it all remade with the RIGHT line ‘throw another steak on the barbie’.'
},function(response){
if (response && response.post_id) {
setTimeout(function(){self.location.href = '/load/preview/page/50908acbe46c03d72dcc26b6';}, 2000);
} else {
setTimeout(function(){self.location.href = '/load/preview/page/50908acbe46c03d72dcc26b6';}, 2000);
}
});
For some reason this javascript redirect after the facebook share it doesn't work on IE8 on SSL.
Does anyone know why?
For some reason this appen just using IE8 on a virtual machine.Without it is fine.
I want to publish to my wall and send invites to friends stylishly.
It seems stream.publish has become depreated now.
Any other method to do this..
I would be obliged if I could have some sample codes as well.
You could use the Feed Dialog:
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:fb="https://www.facebook.com/2008/fbml">
<head>
<title>My Feed Dialog Page</title>
</head>
<body>
<div id='fb-root'></div>
<script src='http://connect.facebook.net/en_US/all.js'></script>
<p><a onclick='postToFeed(); return false;'>Post to Feed</a></p>
<p id='msg'></p>
<script>
FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});
function postToFeed() {
// calling the API ...
var obj = {
method: 'feed',
link: 'https://developers.facebook.com/docs/reference/dialogs/',
picture: 'http://fbrell.com/f8.jpg',
name: 'Facebook Dialogs',
caption: 'Reference Documentation',
description: 'Using Dialogs to interact with users.'
};
function callback(response) {
document.getElementById('msg').innerHTML = "Post ID: " + response['post_id'];
}
FB.ui(obj, callback);
}
</script>
</body>
</html>
You can see it in action in the examples section of the Facebook JavaScript Test Console.
So I hope someone call help me with this issue as I'm not too sure if its javascript, or if its facebook.
Here's my situation. I upgraded to Requests 2.0 on facebook, which no longer gives me the ability to add an exclude_ids field to the form where users will invite their friends to the App. The purpose of this form is not to just invite friends, but to add friends as something in the App.
In short, I have a list of friends that they have already added, and I want to filter that from the master list of their friends so that when they want to use the form, the friends already added do not show up.
Here is my javascript to get the friends:
<script language="Javascript" type="text/javascript">
var friends_filter = '<?=$myClass->getFiltered());?>';
</script>
Will return something like:
999999999,999999999,999999999,999999999,999999999,999999999,999999999
Which is a list of IDs of the users who they have NOT added that are their friends.
Here is my code for the form:
function addUser() {
FB.ui(
{
method: 'apprequests',
display: 'dialog',
title: 'Add friends',
message: 'Hey, I added you as a user/friend on such-and-such App',
data: 'added',
filters: [{name: 'Non-Added', user_ids: [friends_filter]}],
},
function(response) {
if(response && response.request_ids) {
showLoading('Adding Relatives');
var dataString = 'rids='+response.request_ids;
$.ajax({
type: "GET",
url: server_url+"ajax/add_relative.php",
data: dataString,
success: function(data){
window.location.reload();
}
});
}
}
);
}
If you look at the filters: [{name: 'Non-Added', user_ids: [friends_filter]}], line, that is where I include the list of IDS that I only want to see in the selector. The dialog pops up, but then list those ID's in friends_filter and an error message stating "does not resolve to a valid user ID"
This is where I get confused, if I copy and paste what friends_filter outputs and replace it the friends_filter with the list of IDs, i.e. 999999999,999999999,999999999,999999999, exactly as it appears, it works correctly.
I know this is an exhaustive post and I'm sorry, but I'm at my wits end.
The only thing I could think of is that perhaps my javascript variable friends_filter needs to be converted to some type of some sort?
Any ideas?
i was try this code and it is work good with me
FB.ui(
{
method: 'apprequests',
filters: ['app_non_users'],
message: 'msg here!',
title: 'title for box'
},
function(response) {
alert(response.request_ids);//this is return after send invite
}
);
just if you want filter result with list of user use
filters: [{name: 'Invite friends', user_ids: <?php echo json_encode($users_array);?> }],
After much trial and error, I figured out the solution.
in:
<script language="Javascript" type="text/javascript">
var friends_filter = '<?=$myClass->getFiltered());?>';
</script>
I changed to
<script language="Javascript" type="text/javascript">
var friends_filter = [<?=$myClass->getFiltered());?>];
</script>
By replacing the quotes around the php echo with brackets.
Then I changed:
filters: [{name: 'Non-Added', user_ids: [friends_filter]}],
To:
filters: [{name: 'Non-Added', user_ids: friends_filter}],
If you want to exclude those (of your friends) who added the application, you simply use:
filters: ['app_non_users']
I'm using the default stream.publish example in an iframed facebook app with the new SDK.
My problem is that the stream.publish always shows up in a popup window instead of an on page dialog. Does anyone know how to get this old behavior back?
$(document).ready(function(){
$("#streampublish").click(function() {
FB.ui(
{
method: 'stream.publish',
message: 'getting educated about Facebook Connect',
attachment: {
name: 'Connect',
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://github.com/facebook/connect-js'
},
action_links: [
{ text: 'Code', href: 'http://github.com/facebook/connect-js' }
],
user_message_prompt: 'Share your thoughts about Connect'
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
}
}
FB.ui({method: 'apprequests',access_token:'Valid Access Token',display:'iframe',
message: 'You should learn more about this awesome game.', title: 'APP NAME'},
function(response) {
if(response && response.request_ids){
alert(response.request_ids);
}
}
);
Add display:'iframe' in your code as shown above and pass a valid access token.
Reference: http://developers.facebook.com/docs/reference/dialogs/