Facebook Multi Friend Selector (Invite Friends) with Custom Url - facebook

I have implemented FB Multi Friend Selector as explained on this page https://developers.facebook.com/docs/reference/dialogs/requests/
function sendRequestViaMultiFriendSelector() {
FB.ui({method: 'apprequests',
message: 'My Great Request'
}, requestCallback);
}
However I want to send the custom Url to the User, since my Facebook App has some parameters at the end like below
http://apps.facebook.com/MY_APP_NAME/MY_PARAMETERS
However with the above method, the user is getting the following link with the MY_PARAMETERS Omitted
I cann't see any "url" parameter in the "apprequests" method. However, this is something that Sweepstakes does successfully. They are able to pass all their parameters in the Message and I want to copy the same functionality.
Thanks in Advance.

The request will point the accepting user to your canvas URL – there is nothing you can change about that.
However, if you need to pass custom data along “with” the request – there’s the data parameter of the dialog for that. You will get the info you put in there back, after reading the details of the request object from the API.

Related

How to reward members for having their invites accepted in Facebook canvas app?

I'm using the following Javascript for my users to send requests to "invitable friends" from my Facebook app:
FB.ui({
method: 'apprequests',
message: 'Come play with me etc.',
to: str_ids
},
requestCallback
);
function requestCallback(response){
if(response){
console.log(response);
}
else{
//show error to user
}
}
Where str_ids is a string containing the IDs returned by the invitable friends API. This all works fine.
When I invite a single user, let's say his Facebook ID is 1593894704165626, I get the following response:
request
"1399842883640198"
to
["1593894704165626"]
So here I have a unique request ID and the invited person's Facebook ID. I can now store this data in my database along with the inviter's ID, so I have all the necessary info.
However, now I want to reward the inviter after the invitee accepts the invitation and I'm running into a problem.
If user A and user B both invited user C, then when user C joins the game, how do I know whether to reward A or B?
I see from this question that it's possible to pass another parameter along with the invitation, which should help identify the inviter:
Facebook tracking who Invited whom
The first answer here suggests that you can pass such a custom parameter, but doesn't say how. Facebook's convoluted documentation is driving me insane.
Another thing - even if I send that additional parameter, I think there's a problem - for new users the app redirects to the Facebook page that checks whether they want to allow access to the app, and by the time they're redirected back to the app, the additional parameter will be lost.
Is there any solution to this?

Facebook Send dialog with API Error code: 100 ('link' is invalid)

I want to provide users with the ability to send money to their Facebook friends through our app (Exvo) by the means of sending an URL to the invitation page via Facebook.
I'm using the 'Send' Facebook dialog (with a redirect to the Facebook webiste). The exact url I'm redirecting the user to is (to field has been redacted):
https://www.facebook.com/dialog/send?app_id=637466739616439&description=You+can+create+an+Exvo+Account+to+accept+this+money+transfer.&display=page&link=https%3A%2F%2Fwww.exvo.com%2Finvitations%2F9fb77bda665f0ae8f58843daec80a29b&name=Pawe%C5%82+Go%C5%9Bcicki+would+like+to+send+you+0.01+EUR&picture=https%3A%2F%2Fthemes.exvo.com%2Fstylesheets%2Fimages%2Fcustom_images%2Flogo.png&redirect_uri=https%3A%2F%2Fwww.exvo.com&to=username
This present me with a Facebook 'Send' dialog. When I type a custom message and press 'Send', I'm presented with this error:
API Error Code: 100
API Error Description: Invalid parameter
Error Message: 'link' is invalid.
The link param (extracted from the above URL and decoded) is this:
https://www.exvo.com/invitations/9fb77bda665f0ae8f58843daec80a29b
which is a valid URL, returning a proper 200 response. Using the Facebook debugger I can see that the provided URL does not generate any errors:
https://developers.facebook.com/tools/debug/og/object?q=https%3A%2F%2Fwww.exvo.com%2Finvitations%2F9fb77bda665f0ae8f58843daec80a29b
Only warnings about inferred properties (I have added those at one point as well, but it did not help).
Also note, that once in a while (like 1 in 10), when I click 'Send', the message gets through and I don't see any errors, which makes it even weirder.
Why is this error happening? What am I doing wrong?
This might not have been the problem in your case, but just for discoverability: make sure that the URL you are sharing is publicly available on the internet (i.e. not within your firewall or on a local computer). FB needs to visit your URL to verify its authenticity.
Like mpcabd has pointed out above, make sure to remove anything with fb, fbdev, facebook in the url because when I did, it solved the issue for me. It is probably a bug or a security measure by Facebook. You are always required to pass a redirect_uri with the link and try mentioning a title as well.
Also your link and redirect_uri must be within your domain that you have provided for the app. Ex: if your app domain in app settings is http://stackexchange.com, you cannot share a link like say https://stackoverflow.com/apps/php/fbsdk/etc/login.php, instead you have to share the link https://stackexchange.com/apps/php/etc/login.php which has worked for me
echo "<a href='https://www.facebook.com/dialog/send?app_id=YOUR_APP_ID&name=Thanks&link=".$linkToShare."&redirect_uri=".$linkToRedirectTo."'/>Send</a>";
You can also assign $title to something.
I figured out something weird, the same thing happened today on the site I manage, the problem seemed to be that the link contains the word facebook in it, so try to remove [facebook, fb, or f if it was a whole word] from your url, it should work, I had a url like open/ID/facebook/ and the only way it worked when I changed it to fopen/ID/ which looks stupid!
So may be in your case this is the problem:
https://www.exvo.com/invitations/9fb77bda665f0ae8f58843daec80a29b
Try to change your url to something without fb or facebook or anything similar.
I had this issue using the send dialog only. I was using dynamic querystring parameters on a common URL. The common URL has been scraped by Facebook but each iteration of the common URL and the querystring parameters would result in this error if Facebook had not scraped that exact URL previously.
I fixed the issue by forcing Facebook to scrape the URL before I attempt to send it via the FB UI Send Dialog. Use the FB API to hit graph.facebook.com with the URL posted in the id parameter and a scrape parameter set to true.
Like so:
FB.api('https://graph.facebook.com/', 'post', {
id: '[URL]',
scrape: true
}, function(response) {
FB.ui({
method: 'send',
name: '[name]',
picture: '[Picture URL]',
link: '[URL]',
description: '[description]'
});
});
I also answered with this solution to the same problem here.
Doing the following fixed it for me:
shorter token (this string in the link param: 9fb77bda665f0ae8f58843daec80a29b, which was 32 characters long, now is at 16) as advised by gkimsal
accepting October 2013 breaking changes, which required me to introduce OpenGraph tags to the page and drop name, description and picture_uri params that I was including when constructing the Send dialog redirect uri
Now Facebook, before displaying the Send dialog to the user, must fetch my page beforehand to retrieve the data (from OG: title, description and image) required to display a proper dialog to the user. I think this is what helped the most in my case.

Facebook UI, how to check if a user can send facebook message to another user

I want to follow up this question. I use FB.ui to send link and got exactly the same error for some users. Is there anyway to check it and decide whether to display the ui to the user ?
API Error Code: 100
API Error Description: Invalid parameter
Error Message: Viewer cannot message specified recipients.
<a href='#' onClick="
FB.ui({
method: 'send',
link: 'http://www.xxxxxxxxxxx.com',
to: ###########,
});
">Send a message</a>
Even when I use the url send method, some user does not work. For example:
Error User : https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=https://www.bancsabadell.com/cs/Satellite/SabAtl/&to=100000104626944
Normal User: https://www.facebook.com/dialog/send?app_id=123050457758183&name=People%20Argue%20Just%20to%20Win&link=http://www.nytimes.com/2011/06/15/arts/people-argue-just-to-win-scholars-assert.html&redirect_uri=https://www.bancsabadell.com/cs/Satellite/SabAtl/&to=1311251197
(this is the share link example taken from https://developers.facebook.com/docs/reference/dialogs/send/)
bug reported to facebook: https://developers.facebook.com/bugs/538638372825668
Edit: in fact, everyone should be reachable through messages now. It's only there are new "filtering preferences". I guess this can_message field is now useless because it should always return true. I think it is going to be deprecated in a while.
In the user FQL table, you have a field that must verify what you need:
can_message (boolean): whether the user can send a message to another user
Source: https://developers.facebook.com/docs/reference/fql/user
select can_message from user where uid=USER_ID
USER_ID being the person that your app user want to send a message to.
You can use the FB api;
I use something like:
FB.api('/me/permissions', function (response)
{
//check contents of response for required permissions here
fb_publish_perm = response.data[0]['publish_stream'] ? response.data[0]['publish_stream'] : false;
if (fb_publish_perm)
{
// it permissions exist
}
else
{
// permissions dont exist launch the ui to request.
}
});
Please treat the above as psedo code, as it came straight off the top of my head!

How get the notification ID when user enter in you app

I'm using the Facebook requestdialog to show my friend list and invite,this in a Facebook Web APP, using this:
function sendRequestViaMultiFriendSelector() {
FB.ui(
{
method: 'apprequests',
message: 'Selección de amigos a los que invitar a KugaBar'
}, requestCallback);
}
function requestCallback(data) {
console.log(data);
}
It works (ok).
But I need to identify the user when enter in my APP, you see the requestCallback data and see a "request", but when the users click on the notification and enter in the APP
I don't know how identify the request to detect if the user is accessing by the notification.
EDIT: OK I found it.
The param in the GET vars are "request_ids", but one problem appear, this param only come if the user previously have accepted the permissions, if the user clicks on the notification, and accept the permissions, hitting enter: this param doesn't exist, if the user enter again (not need to accept nothing) this param exists in the URL.
Are there any method to get this param in the first time the user enter?
Thanks
When the user first clicks on a request, you should get the request_id from the URL and store it in a cookie. When the user has completed logging in, check if the cookie exists and then update your record accordingly.
Notifications and Requests are NOT the same thing on Facebook. In your case you're talking about Requests. Request ids are passed to the app as a GET parameter 'request_ids' which is a comma separated list.
To be able to access this parameter after login dialog, you want to save your GET parameters from the original launch URL before redirecting to the OAuth dialog and pass them around in the redirect URL. This way you solved this problem for all of your future GET parameters.
If you're using PHP, the function you're looking for is http_build_query. I'd highly discourage from using a cookie to store one-time and easily accessible URL parameters.

Facebook Multiple invites using Requests 2.0

Is it possible to send multiple invites using new Requests 2.0? Documentation as of now saing that 'to' parameter can specify only one user, so it single user or standart request dialog even without possibility to set default filter! It's huge drawback from hidious by nature, but effective in purpose FBML.
Sure.
Look in the docs for Requests 2.0:
Send to Many
From your application front-end,
execute:
FB.ui({method: 'apprequests', message: 'You should learn more about this awesome game.', data: 'tracking data: 'tracking information for the user'});
This will open the facebook Dialog:
If you meant in your question whether or not you can filter multiple id's - meaning, you choose the list of uid's to send the request to and not the user - then the answer is no, it's not possible currently.
Of course.
FB.ui({
method: 'apprequests',
message: 'text for the receiving user',
data: '127', // to know what to do with it.
title: 'title of window.'
});
see this fanpage for an example:
http://www.facebook.com/NeonFashion?sk=app_176086155780033
or i missunderstand your questions and you actual looking for something like
Facebook requests 2.0 filter
It is (now?) possible to open a request dialog targeting multiple users at once, by passing an array of ids in the "to" field.
See the "sendRequestToManyRecipients" example in https://developers.facebook.com/docs/reference/dialogs/requests/