- Home /
Facebook SDK - Send lives between users - FB.API() problem
Hello everyone,
I want to send lives between players. I'm trying to get the object ID with FB.API but I can't.
This is my code:
Dictionary<string, string> formData = new Dictionary<string, string>();
formData["og:url"] = "http://samples.ogp.me/746045498766635";
formData["og:title"] = "Sample Life";
formData["og:type"] = "bubbleparadisetwo:life";
formData["og:image"] = "https://fbstatic-a.akamaihd.net/images/devsite/attachment_blank.png";
formData["og:description"] = "";
formData["fb:app_id"] = "730922200278965";
FB.API("/app/objects/bubbleparadisetwo:life", HttpMethod.POST, SendLiveCallback, formData);
And the result is:
"java.io.FileNotFoundException: https://graph.facebook.com/app/objects/bubbleparadisetwo:life"
Can you help me? Thanks in advance,
Joel
$$anonymous$$ore information: - The object type "Life" has been created in the Open Graph page. - The login to Facebook is: FB.Login("public_profile,email,user_friends,publish_actions", AuthCallback);
I would suggest that you use a separate server to manage this. Facebook discourages using its open graph for anything other then social functions.
Sending objects between users is a typical option in games with facebook integration and I think it's a social function. Am I wrong?
Answer by jsr2k1 · Nov 14, 2014 at 03:46 PM
Solved!
Dictionary formData = new Dictionary();
formData["og:title"] = "Sample Life";
formData["og:type"] = "bubbleparadisetwo:life";
formData["fb:app_id"] = "730922200278965";
Dictionary formDic = new Dictionary();
formDic["object"] = Facebook.MiniJSON.Json.Serialize(formData);
FB.API("me/objects/bubbleparadisetwo:life", HttpMethod.POST, SendLiveCallback, formDic);
The question now is how to ask for lives???
I can use FB.AppRequest with OGActionType.AskFor ... but what ObjectId then if it's not yet created?
hello @jsr2k1,
I am just using your code to generate object in facebook. but i don't get any success.
Dictionary<string,string> formData = new Dictionary<string,string>();
formData["og:title"] = "mazetest"; // I think any name is possible
formData["og:type"] = "gamemazerace:maze"; // og:type
formData["fb:app_id"] = "192399180931956"; // app id.
// Dictionary formDic = new Dictionary(); // Your code but i got error.
Dictionary<string,string> formDic = new Dictionary<string,string>();
formDic["object"] = Facebook.$$anonymous$$iniJSON.Json.Serialize(formData); // I don't know what is fromDic["object"]?
print ("formDic : " + formDic.Values);
FB.API("me/objects/gamemazerace:maze", Http$$anonymous$$ethod.POST, SendLiveCallback, formDic);
I don't get any error. but new object is not created in object browser
I have few questions.
Where you get object ID?
and what is fromDic["object"]?
Finally, I did this:
Create an object "Life" instance directly in the Object Browser (facebook developer dashboard).
Copy the objectID and use it in my code.
Always use the same objectID to send lives between users.
Asf for one life with:
FB.AppRequest("Ask for one life",OGActionType.AskFor, objectId, FriendSelectorFiltersArr, excludeIds,maxRecipients, FriendSelectorData,FriendSelectorTitle, callback : CallbackAskForOneLife );
Send one life with:
FB.AppRequest("Send one life", OGActionType.Send, objectId, new string[]{user}, FriendSelectorData, FriendSelectorTitle, callback : Callback );
Delete all requests with:
FB.API("v2.2/"+requestID, Http$$anonymous$$ethod.$$anonymous$$ETE, Callback);
Thank you, @jsr2k1,
I will try that. I want to send some different data to other player. i think it can't possible with only one object.
I make progress on this question. I will update once it done correctly.
and i have one more question. may i want to delete object same as request?
I don't delete the object because I use it every time to send lives.
@jsr2k1, thank you for your steps, they really helped alot. I am facing one problem, if you can help me, I will be very grateful. How to accept the app request when I tap the notification?
Answer by Saddamjit_Singh · Jun 19, 2017 at 09:43 AM
Hi, where i can find Open Graph page on my developer account? @js2k1
want to implement send and ask gift feature in unity using facebook. Till now i have created an object in object browser and using this code after that -
public void Object$$anonymous$$anagement()
{
Dictionary<string,string> formData = new Dictionary<string,string>();
formData["og:title"] = "Shots";
formData["og:type"] = "Object";
formData["fb:app_id"] = "921871194580745";
Dictionary<string,string> formDic = new Dictionary<string,string>();
formDic["object"] = Facebook.$$anonymous$$iniJSON.Json.Serialize(formData);
Debug.LogError ("formDic : " + formDic.Values);
FB.API("me/objects/Shots", Http$$anonymous$$ethod.POST, CreateFBLifeCallback, formDic);
}
public void CreateFBLifeCallback(IGraphResult result)
{
if (!string.IsNullOrEmpty(result.Error))
{
Debug.LogError("Error during object create call! " + result.Error);
}
else if (FB.IsLoggedIn)
{
Debug.LogError("ok during object create call! " + result.Error);
}
}
Nothing is working and i am also trying to send gift by using this code -
{
//string objectId = "464873603864100";
string objectId = FBData.userid;
FB.AppRequest (
"Free Coins",
OGActionType.SEND, // Can be .Send or .AskFor depending on what you want to do with the object.
objectId, // Here we put the object id we got as a result before.
SendGiftRecipient, // The id of the sender.
"this is just testing data", // Here you can put in any data you want
"Send coins to your friend", // A title
AppSendGiftCallback
);
}
i am getting
Object type 'Object' for ID '464873603864100' is not owned by this app
issue . pls hlp to resolve
yes, because open graph objects are deprecated now.