To invite friends in facebook I used following code
FB.init({
appId:'APP_ID',
cookie:true,
status:true,
xfbml:true
});
function FacebookInviteFriends()
{
FB.ui({
method: 'apprequests',
message: 'Your Message diaolog'
});
}
Its giving as shown below
But what I need is
click here to see
How can I get it.
FB.ui({
method: 'apprequests',
message: 'Your Message diaolog',
to: 'uid1,uid2'
});
Related
I am working with the FB Javascript send dialogue. I am wanting the iframe/popup to redirect to another url so I can mark that the FB message has been sent. However redirect_uri doesn't seem to be working.
<script>
function test(){
FB.init({appId: 'xxxxxxxxxx', xfbml: true, cookie: true});
FB.getLoginStatus(function(response) {
//call dialog her
FB.ui({
method: 'send',
link: 'http://www.google.com',
redirect_uri: 'google.com',
picture: 'http://fbrell.com/f8.jpg',
caption: 'Reference Documentation',
description: 'Dialogs provide a simple, consistent interface for applications to interface with users.',
redirect_uri: 'http://127.0.0.1:4567/home'
});
});
}
</script>
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"
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?
I use this function that prompts the end user to choose multiple friends to invite:
function sendRequest() {
FB.ui({
method: 'apprequests',
message: 'Check out this application!',
filters: ['app_non_users'],
title: 'Send your friends an application request',
}
This works preety good, But i want to limit the number of friends the user
can invite in the popup facebook ui. How can i accomplish this?
request_ids = FB.ui({
method: 'apprequests',
access_token: '<?php echo $_SESSION['facebook_access_token']; ?>',
display: 'iframe',
max_recipients: '5',
message: 'message',
data: 'data' });
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!