Facebook Dialog Feed - Hide share via link - facebook

I am using FB UI for sharing using feed method.
The page is sharing correctly.
Can anyone tell how to hide the share via "Facebook Application Name" link.
I'm using following code.
FB.ui(
{
method: 'feed',
name: '<?php the_title(); ?>',
link: '<?php echo $urlofpage; ?>',
picture: '',
caption: '<?php echo bloginfo('siteurl'); ?>',
description: '',
message: ''
},
function(response) {
if (response && !response.error_code) {
if ( response && response.post_id ){
$.ajax({'url' :'http://graph.facebook.com/?id=<?php echo $urlofpage; ?>','success':function(data){
get_like_count(data.shares);
}});
}
}
}
);

You can´t hide that text, and it´s very important anyway. People should know if something got posted via an App and not by the user directly.

Related

redirect user after share facebook

i want to redirect users to a specific page after they share on facebook, i have found a good answer here at:
redirect user after facebook share and publish
here's the script
<script type="text/javascript">
FB.init({appId: "YOUR_APP_ID", status: true, cookie: true});
function share_me() {
FB.ui({
method: 'feed',
app_id: 'YOUR_APP_ID',
link: 'SHARE_URL',
picture: 'PIC_URL',
name: 'SHARE_NAME',
caption: 'SHARE_CAPTION',
description: 'SHARE_DESCRIPTION'
},
function(response){
if(response && response.post_id) {
self.location.href = 'SUCCESS_URL'
}
else {
self.location.href = 'CANCEL_URL'
}
});
}
</script>";
<div onclick="share_me()">Share</div>
but when i used the script ,there's no redirect at all, even if the user click "cancel"
please help me with this as am searching for a method like this since 1 week!
Try using another javascript function for redirecting like window.location = "YOUR_PAGE"

facebook api with private message multiple to (friends)

I development facebook private message for invite with facebook api.
<script>
FB.init({ appId: 'xxxxxxxxxx', xfbml: true, cookie: true });
FB.ui({
method: 'send',
to: ['1736383768','590528674'],
// picture: 'http://thinkdiff.net/iphone/lucky7_ios.jpg',
//Can be page, popup, iframe, or touch.
display: 'popup',
name: 'yyyyyy',
link: '<%=Request.QueryString["link"]%>'
});
</script>
but adds only the first mate.
how to multiple friends send private message ?
var publish =
{
method: 'stream.publish',
message: 'Some kind of test',
uid: uid,
attachment: {
name: 'Test',
caption: 'Facebook API Test',
description: ('Sure hope it worked!'),
href: 'http://www.test.com/',
media: [
{
type: 'image',
href: 'http://test.com/',
src: 'http://test.com/image.jpg'
}
]
},
action_links: [
{ text: 'Your text', href: 'http://www.test.com/' }
],
user_prompt_message: 'Share your thoughts about test'
};
publish.target_id = friendID;
FB.ui(publish);
publish.target_id = friendID;
FB.ui(publish);
return false;
You should not use stream.publish.
As said by facebook : "We are in the process of deprecating the REST API, so if you are building a new application you shouldn't use this function. Instead use the Graph API and POST a Post object to the feed connection of the User object"
So, now you have the send and feed methods left.
You cannot fill the send method with more than one user id (you can only if you are whitelisted by facebook, but I'm not quite sur how to do this , I would not count on it either).
You can use the feed method to post on many user's friends wall with something like this
FB.api('/USERID/feed', 'post', {
name:postName,
link:postLink,
picture:postPicture,
description:postDescription,
message:postMessage
}, function (postResponse) { //DO SOMETHING HERE });
But doing it, you are taking the risk of your app being deleted by facebook if someone flag it as spam.
As far as I know, sending messages to multiple friends via an App is considered bad/spam by facebook so they do not allow this anymore.
You still can Invite as many friends as you want via the App request dialog (method apprequests) but I'm not sure this is what you want.

facebook request_uri not working

The invitation dialog pops up fine and invitation is also sent. But i am unable to redirect the user to desired page after sending the invitation using redirect_uri as stated in Requests Dialog facebook documentation (https://developers.facebook.com/docs/reference/dialogs/requests/). There is no redirection or anything after sending invitation.
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : 'app_id',
});
function sendRequestViaMultiFriendSelector() {
FB.ui({method: 'apprequests',
message: 'Invite friends!',
request_uri: 'https://apps.facebook.com/myappname/invitesent.php', data: '<?php echo $user_id; ?>', exclude_ids: [<?php echo $friends; ?>]
}, requestCallback);
}
function requestCallback(response) {
// Handle callback here
}
</script>
You don't need the redirect_uri if you are using the JS-SDK. This is the job of the callback function, so in your requestCallback():
function requestCallback(response) {
// Handle callback here
...
// once done, redirect (outside of Facebook page!)
top.location.href = 'http://mydomain.com/nextpage/';
}
Or I suppose location.href = ''; to stay in the Facebook app frame.
As you have already included Facebook javascript SDK in your App
and you have writen this code for inviting friend for your App in a script
FB.ui({ method: 'apprequests',
redirect_uri: 'APP URL',
message: 'My Message'
});
This will redirect to App URL without redirecting to Facebook canvas URL.So this will not work even if you use data parameter such as
FB.ui({ method: 'apprequests',
data: 'APP URL',
message: 'My Message'
});
Write this code at your App landing page i.e. in index.php at beginning of the code.
$requestid=$_GET[request_ids];
if(!empty($requestid))
{
echo "<script> window.top.location.href='APP URL'; </script>";
}
Have you given callback canvas url when you create facebook application?

facebook application, inviting friends after the completion of status update feature

i am making a facebook application, everything seems done.
here is the sample flow(index.php):
seekpermission.php
processinfo.php
generateresult.php
poststatus.php(the javascript way as told in the documentation)
invitefriends.php(the javascript way as told in the documentation)
hope the names are self explanatory.
the trouble is the dialogue to update status and invite friends comes almost parallely, but what i want is once the user publishes/skips the status message only then should the dialogue of invite friends should come. here is what i tried but it is not working, please help thanks!
FB.ui(
{
method: 'feed',
name: 'name goes here',
link: 'http://apps.facebook.com/****/',
picture: '<?php echo $imageurl; ?>',
caption: 'here is caption',
description: 'the description',
message: '<?php echo $charecter; ?>'
},
function(response) {
if (response && response.post_id) {
alert('<?php include "invitefriends.php"; ?>');
} else {
alert('<?php include "invitefriends.php"; ?>');
}
here is the invitefriends.php
<body>
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js">
</script>
<script>
FB.init({
appId:'2****', cookie:true,
status:true, xfbml:true
});
FB.ui({ method: 'apprequests',
message: 'Folks check out my new facebook app!! visit http://apps.facebook.com/**** '});
</script>
</body>
Well, that's a weird way to accomplish a simple task:
You can combine step 4 & 5 in one step:
FB.ui(
{
method: 'feed',
name: 'name goes here',
link: 'http://apps.facebook.com/****/',
picture: '<?php echo $imageurl; ?>',
caption: 'here is caption',
description: 'the description',
message: '<?php echo $charecter; ?>'
},
function(response) {
FB.ui({ method: 'apprequests',
message: 'Folks check out my new facebook app!! visit http://apps.facebook.com/**** '});
/* if (response && response.post_id) {
alert('<?php include "invitefriends.php"; ?>');
} else {
alert('<?php include "invitefriends.php"; ?>');
} */
}
)
As you can see no need for the if else since you will force the invite anyway!
Now if you really need to use your approach, then you may use something like (in the response:
location.href='<?php echo 'path/to/invitefriends.php';
IMPORTANT NOTE:
Most likely ALL your 5 steps can be combined in ONE file, this is better because:
You don't need to load and initialize the JS-library FIVE times!
Will be a better user experience instead of loading each time
You can wrap all the Facebook Calls in JS functions and just call each one in the response of the previous one!

Facebook code to prompt for stream publish with in application

I have a bit confusion using facebook API. I am using a code that is working out side of facebook but not in facebook application canvas page.
I have bit idea but not sure. Can anybody let me know the reason behind this and the code that will run in facebook application.
What is difference you run code using application like
http://apps.facebook.com/exampleAPP/test.php
or normal url
http://www. example.com/example/test.php
http://www. example.com/example/ is the canvas URL
<div id="fb-root"></div>
<script src="http://connect.facebook.net/en_US/all.js"></script>
<script>
FB.init({
appId : '115454544334343454',
status : true, // check login status
cookie : true, // enable cookies to allow the server to access the session
xfbml : true // parse XFBML
});
FB.ui(
{
method: 'stream.publish',
attachment: {
name: 'JSSDK',
caption: 'The Facebook 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/'
},
action_links: [
{ text: 'fbrell', href: 'http://fbrell.com/' }
]
},
function(response) {
if (response && response.post_id) {
alert('Post was published.');
} else {
alert('Post was not published.');
}
}
);
</script>
I'm fairly sure stream.publish is deprecated and unsupported. What you want instead is the Feed dialog.