Silent Facebook app request to specific facebook user - facebook

I'm using this code:
FB.ui(
{
method: 'apprequests',
message: "An invite',
title: 'App Request',
to: intFB_ID
}, requestCallback);
..but when I run it, it brings up a confirmation request dialoge box, which I have to physically click to 'Send Request'.
Is there anyway to send an App Request silently, in that there is no confirmation required, and so can be run on a Cron or as a batch?
Thanks

The code snippet you provided sends a "user generated request" and there's no way to do that without that specific dialog, so no you can not do it with no confirmation on the user side.
What you can do how ever is send an "app generated request" for the user instead.
The end result will be different though.
The two options are described in the Social Channels doc (under the Requests section).

Related

Facebook API Send dialog

Here is my send javascript code:
function send(id, description, title) {
FB.ui({
app_id: '390841657651335',
method: 'send',
description: description,
link: http://vic.bg/Vits.aspx?vicid=' + id,
name: title
}
}
Send is always ok (i dumped the response from the callback to the console), but recients got that message
Attachment Unavailable This attachment may have been removed or the person who shared it may not have permission to share it with you
instead of the actual post. Did someone face that problem?
The problem was with the settings of the application Sandbox Mode: was checked.
I do not know why they display such strange message in that case
So, did the 'send dialog' worked for you? because from all of my research and reading all posts related, facebook currently doesn't allow to send private messages to friends through graph api..
I'm trying the 'send dialog' via a direct URL and not via JS SDK.

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

Is it possible to customize the apprequest notification message similar to BranchOut?

I've noticed that BranchOut requests have a custom notification message and stand apart from other app requests in my notifications.
Is this because BranchOut has a special partnership with Facebook?
The documentation states that the "message" value will not be displayed in the notification, so I'm curious how this is being done.
No it is not possible even with new_style_apprequest parameter in FB.ui options. This used to work earlier but it has stopped working lately. It was anyways an undocumented feature. This is my guess that you might require special permissions from Facebook to be able to achieve this.
it's definitely possible, using the parameter new_style_message set to true - you can double check this by reverse engineering their Javascript API library.
This is a sample code
FB.ui({
display: 'iframe',
method: 'apprequests',
new_style_message: true,
title: "Join my network",
message: "would like you to join his network",
to: [list of user ids to invite]
});

Track use of send dialog

I'm using the Fb.ui send dialog to hopefully allow users to connect to other users. I want to know if there is anyway to track the use of this dialog box so I can tell if users are taking advantages of it.
You could track the usage of the send dialog by putting in some simple tracking at 3 different stages
User clicks on your 'send message' button to open the dialog
User opens the dialog but clicks cancel
User opens the dialog and then sends a message
Here's some sample code demoing how you can add a callback to the send dialog and determine whether or not the user actually sent a message. Although please note that there seems to be some issues with this at the moment and I'm not totally sure that the send dialog supports callbacks fully yet.
FB.ui({
method: 'send',
name: 'Google',
link: 'http://www.google.com',
},
function(response) {
if (response) {
// user sent the message
} else {
// user clicked cancel
}
});
In the callback function, trigger an ajax call to a php script that will recored the call in the database.
This way you'll know how many time the dialog was used, and by which user.

posting reply to inbox message?

I'm trying to post a reply to an inbox message by sending a POST request to /message_id/comments. Is this the correct way to send a reply to an inbox message ?
I'm getting the following error:
"error": {
"type": "OAuthException",
"message": "(#3) App must be on whitelist"
}
The token has every possible permission.
Do I have to ask that my app is added on a whitelist ? how to do so ?
I'm doing this in javascript+jQuery:
var params = {
access_token: token
, method: 'post'
, message: 'hi'
};
$.getJSON('https://graph.facebook.com/$message_id/comments?callback=?', params, function(json) {
});
Facebook apps by default aren't allowed to send messages on behalf of users. There is no permission you are missing. This is an extra level to prevent spam (beyond prompting the user who). You will have to contact Facebook to get your application whitelisted. I would try their developer group.
opened a support ticket right here:
http://developers.facebook.com/bugs/183144141763793?browse=search_4e8b140cbf26e6040457329
Tried all I can think of and googled for, still getting this issue
Like others have pointed out, there isn't a way to do this programmatically unless you are on Facebook's whitelist. However, I did find a way around this for my app. What I do is use Oauth to display messages from a user's FB inbox like normal. When the user clicks 'Reply' on a message, I just send them to the reply page on Facebook Mobile, like this:
$('.reply').click(function() {
var popup_window = window.open('http://touch.facebook.com/messages/compose?ids='+message_id, '_blank');
popup_window.focus();
});
Where message id is the Facebook id for the message they are replying to. In my case, I use PHP to echo the message id into a javascript variable or data-attribute when the page loads. Since the Facebook mobile page opens in a new tab, they don't even really leave my app. Since Facebook mobile has a very streamlined interface it isn't too distracting. It's not perfect, but it works and it's easier than trying to get whitelisted.