FB.AppRequest does not work - facebook

I am trying to send App Requests with Facebook SDK on Unity. Everything is alright until I press 'send'. It also returns a success but nothing happens in my friends' facebook :S
FB.AppRequest(message, null, null, null, null, null, title,
(result) => {
Debug.Log(result.RawResult);
}
);
As you can see, I am able to show the friends list and select the ones who will receive the request. After pressing send, it returns a success(I have put the Xs intentionally). However, nothing happens on my friend's facebook.
{"to":"10XXXXXXXXXXXXXX33","request":"161XXXXXXXXXXXXXX89","callback_id":"4"}

I have assigned my friend receiving the request as administrator so that he was able to get the notification. Otherwise, he does not get anything because the facebook app is currently in development mode.

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/Unity OpenGraph: Object with ID ' ' cannot be retrieved

I am currently trying to get Facebook to send an Open Graph object from within my Unity game however something weird is happening. I have the object set up within the Open Graph settings page, and I have done all of the set up required to get the actual object ID and everything. The image is hosted, the POST object data changed etc. The function I am calling contains the following:
FB.AppRequest(
message: "I sent you a life!",
actionType: Facebook.OGActionType.Send,
objectId: livesIdValue*,
filters: null,
excludeIds: null,
maxRecipients: null,
data: "",
title: "Send a life to your friends",
callback: sendLifeCallback
);
*livesIdValue is set to the ID that was returned from the Graph API Explorer.
The strange thing about this is, on one Facebook account, this works completely fine, and will show the Friend Picker dialog window thing. When I try it with a second Facebook account though, I get the error message:
"Object with ID 'value that is stored in livesIdValue' cannot be retrieved.
Has anybody run into this problem? I'm really not sure what could be causing this problem to only show up on one account but not the other.

400 Bad Request when implementing custom friend selector

I'm trying to implement a custom multiple friend selector to invite users to my game. I get the list of users calling the Graph API call InvitableFriends, and create a UI for it.
After the user selects the corresponding users, I get all the invitation tokens of the users, and make a call to an App Request as follows:
public void InviteFriends(string message, string title, FacebookDelegate callback, string[] to = null, string data = "")
{
if (FB.IsLoggedIn)
{
FB.AppRequest (message,
to,
"",
null,
null,
data,
title,
callback);
}
}
But when the call is made, I'm getting the following error:
400 Bad Request
UnityEngine.Debug:LogError(Object)
FbDebug:Error(String)
Facebook.FallbackData:JSFallback(String)
Facebook.AsyncRequestDialogPost:CallbackWithErrorHandling(FBResult)
Facebook.<Start>c__Iterator0:MoveNext()
My callback function is never called, so I can't see what the error is.
I'm using Unity 4.3 & Facebook SDK 5.1
Thanks for your help!
EDIT: I'm pretty confident that the issue is that in the TO parameter I'm passing the invite tokens that the Invitable Graph call is giving me, AND NOT THE Ids.
I tested the InteractiveConsole.cs example of friendsmash with the invitable token and it also failed. How can I get the ids of the invitable friends?
just check the url request. It may be some thing wrong with it.
or
go to https://developers.facebook.com/apps/{app-id}/app-details/
in "app Info" section, choose the proper category and sub category.
I had a similar issue.. Figured out that FB.init() has to be called before using the invitable api. Without it you would get a "400 Bad Request"
I was keeping the old access token in playerprefs and just checking it again for validity and not actually initialising FB to save load time. But eventually I had to do FB.init()

Error: cannot invite friends using Facebook SDK for Unity

I was wondering if somebody can help me to solve this problem. I am trying to use FB.AppRequest() in Facebook SDK for Unity to implement an Invite feature . This is the code which I use.
if(FB.IsLoggedIn)
{
FB.AppRequest(
message: "Let's eat and be prosperous!",
title: "Let's eat and be prosperous!",
callback: InviteCallback
);
}
// ...
void InviteCallback(FBResult response)
{
// print response to console
}
The invitation dialog which I get can be seen here (link to Imgur). There is no "Invite" label on those buttons, and unsurprisingly, clicking them does not send any invitation. However, I can see the FBResult data, which is in the following format:
{
"request": "ABCD",
"to":
[
"EFGH",
"IJKL"
]
}
(more or less, since I haven't found a way to print new lines to Firebug console)
Additional information:
The result is the same regardless of the Sandbox setting.
The Unity version is 4.3.0f4
The Facebook SDK for Unity version is 4.3.4
The binary is hosted on an intranet server.
The Invite functionality in the Friend Smash example, hosted on the same server, doesn't work either. However, this is before the latest Friend Smash update (11/11/2013), whose Facebook functionalities I can't get to work yet.
Other Facebook functionalities (e.g. Init, Feed, API) work well.
I can't find any information about this on the internet. There are other questions about the Invite feature not working, but without the Facebook SDK for Unity, so I am not sure how they can be helpful to me.
Thanks a lot!
Just to clarify: the envelope button sends the invite, and it does so immediately when it is clicked.
If your app is in sandbox mode, people won't get notified when the request is sent. Look for the request in https://www.facebook.com/appcenter/requests as the recipient and see if the request shows up there.
If this still doesn't work, can you send me your fbresult data? unity-sdk#fb.com. thanks!

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.