How to Display success message after Request sent using facebook dialog? - facebook

I have an app on facebook. I can send request OR post to feed on share but I am facing problem after sending request.
I want to display success message. Something like your requests has been sent.
Actually if I talk more specifically, I need code to display success message (requestCallback code required) after sending request from facebook dialog.
I am working on my facebook game application: http://apps.facebook.com/siegiusarena
Any reference link OR code for requestCallback handler would help.

FB.ui({ method: 'apprequests',
title: 'Title',
message: 'Message'
},
function (res) {
if (res && res.request) {
// do something if the request was created
alert('your requests has been sent');
// or maybe something like that
$('#messagecontainer').text('your requests has been sent');
}
else if (!res) {
// do something if the request was not created
}
});
EDIT:
If you want to show dialog with success message that simply looks the same as FB dialogs there are 2 ways:
1) You can use library/plugin that is designed to do this, like Facebox - http://defunkt.io/facebox/
2) You can style, for example, jQuery UI dialog on your own to achieve that, something like that - http://www.neilyoungcv.com/blog/code-share/emulating-facebooks-dialogue-using-jquery-ui-dialogues/

Related

deleting facebook requests

The facebook docs here say "it is the Developers' responsibility to delete a Request once it has been accepted". As far as I understand, when someone sends a request to multiple users on facebook like this:
function sendRequestViaMultiFriendSelector() {
FB.ui({method: 'apprequests',
message: 'test message'
}, requestCallback);
}
only one request_id is returned via requestCallback() function.
Then, if I delete the request when someone accepts it, how would other users accept the deleted request?
when user comes following the app request, you can get request id's using
$_GET['request_ids']
then retrieve all the request ids with which you can call graph api to delete the corresponding requests like below:
if(isset($_GET['request_ids']))
{
$request_ids = $_GET['request_ids'];
}
$request_ids = explode(",", $request_ids);
foreach($request_ids as $request_id)
{
$full_request_id = $request_id."_".$fbid; //$fbid is current user facebook id
$facebook->api("$full_request_id","DELETE");
}
Check out the Request ID Format section of the FB request overview page.
The actual graph path for a request actually sent to specific user is "request-id"_"recipient-user-id".
you can access to facebook on mobile mode (m.faceook.com)
1-access the invitation panel
2-display all the invitations
3-open console mode in chrome
4-activate jquery by cpying and pasting all the jquery.min code into console
and excecute this script :
$("._54k8._56bs._56bt").trigger("click");
that will cancel or the invitation sent

Facebook request dialog with custom messages like Branchout

How does Branchout custom their Request Dialog messages? There is no option for this.
The documentation https://developers.facebook.com/docs/reference/dialogs/requests/ doest mention any extra parameters, only app_id, redirect_uri, message ,to , filters , exclude_ids , max_recipients, data, title.
As im a new user, i cant post images.. Here are the links: http://i.imgur.com/37tju.png ,
Im using the following javascript to call the facebook function:
FB.ui({
method : 'apprequests',
message : 'Message itself',
title : 'Title message',
display : 'iframe',
access_token : '(access_token)',
to : uids
}, function(response) {
if (response)
{
// handle callback.....
// (...)
}
});
There are some APIs with special privileges. You have to get a way of get in touch with Facebook. I don't know any docs for it.
there is no need to have special partnership to do such a thing.
Please check Is it possible to customize the apprequest notification message similar to BranchOut?

Facebook JS SDK: FB.ui callback doesn't work - need working example code

When I use the Send dialog using the Facebook JS SDK FB.ui call, the callback does not trigger.
FB.ui(
{
method: 'send',
to: ****, // fbId
redirect_uri: *****, // public URL in my app domain
link: ***** // public URL
},
function(response) {
alert('callback was called!');
if (response != null) {
console.log('Request was passed along!');
location.href= ***; // just in case redirect_uri doesn't work
return true;
}
else {
console.log('Not passed along. User clicked cancel');
}
}
);
Expected behavior: The alert should be shown. The console message should be logged. And the user should be sent to the redirect_uri.
Actual Behavior: None of these 3 things happen. The Send dialog opens and the to: field is pre-populated correctly. When I click Send, it is sent correctly. But I need the callback to be triggered and the user needs to be sent to redirect_uri.
Remove the redirect_uri item and the call back will be fired.
I was facing the same issue a few mins back and realized that removing the redirect_uri solved it.
Every FB.UI has a callback function and it applies to Send dialog also.
See this document for general syntax for FB.UI.
But the problem is as other FB.UI methods, SEND method doesn't have a return value.
As per Facebook documentation ,
If sending the message is successful, the user will be redirected to the redirect_uri. Otherwise, an error will be shown. Unlike the Like
Button, there is no return value per se.
So if the message sending is successful and you dont have a redirect_uri then the callback will have nothing as a return value and otherwise sends error when message sending is failed.
To confirm that callback is working use the following code,
FB.ui({
method: 'send',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html',
},
function(response){
alert(response);
if(response != null){
alert('user clicked send');
}else{
alert('user clicked cancel');
}
});
when you click send and message is sent successfully , it will alert an empty string and when u click cancel it will alert 'null'.
Have you verified on other browsers? Check your browser settings once.
Do you have an extension like "Facebook Disconnect" installed?

Is it possible to get the number of users messaged by the send dialog

I'm wondering if its possible to retrieve the number of people/friends messaged by a user when they use the 'send dialog' to send specific friends a messages (just a number is ok). I've been looking through the documentation for the send dialog but it doesn't seem to have any information regarding this.(https://developers.facebook.com/docs/reference/dialogs/send/).
An alternative I can think of at this stage would be to use the graph API, but then I'd need to know the messageID of the message the user just sent.
yes you can get the count
first :you should know when user sent a message Check the link below
here is a sample for you
to test it :
http://www.fbrell.com/saved/d002a25a351e6b01b0526b2606b48750
<script>
FB.ui({
method: 'send',
name: 'People Argue Just to Win',
link: 'http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html',
},
function(response) {
if (response) {
alert('message sent.');
} else {
alert('not sent');
}
}
);
</script>
second:use jQuery & via jquery load ($().load('page.php');
you can save who sent message with uid & of course you can get count every time you want

Facebook API: Suggest page to friends and view which are were selected

I am developing an application which is based on user challenges. The app also requires a Facebook account to play.
I want a user to be able to select a bunch of friends he wants to challenge and send them an "invitation". But besides this, I need to find which friends did the user invite in order to save them to my database and "prepare" the challenge.
I managed to do the select-friends-dialog using this, but have no idea how to retrieve the selected users. Also, does this work on non-canvas Facebook applications? As I read that page, I am not sure whether it will work for my non-canvas application.
Here is my select-friends-dialog code:
function challengeFriends(){
FB.ui({
method: 'apprequests',
message: 'message",
title: 'title'
});
}
Any help is highly appreciated! Thank you.
I've written a tutorial that covers what you are asking for and other aspects of the Request dialog: How To: Send An Application Request Using The Facebook Graph API
The idea is to capture the request ids from the callback and save them in your DB, and within the request itself you can find the invitee id (friend id):
FB.ui({
method: 'apprequests',
message: 'Check out this application!',
title: 'Send your friends an application request',
},
function (response) {
if (response && response.request_ids) {
var requests = response.request_ids.join(',');
$.post('handle_requests.php',{uid: <?php echo $uid; ?>, request_ids: requests},function(resp) {
});
} else {
alert('canceled');
}
});