首页 > 解决方案 > 如何使用 facebook graph api 创建对象,用于统一游戏?

问题描述

我正在学习如何在 unity3d 游戏中使用 facebook 图形 API,创建对象以使用它们向玩游戏的朋友索取礼物,发送挑战以邀请玩。

我尝试使用图形 API 添加它们,

{
 "app_id":29xxxxxxxxxxxxx,
 "type":"testapp:life",
 "url":"https:\/\/apps.facebook.com\/appname",
 "title":"Life",
 "description":"Use this life to play another time!"
}

得到以下结果,

{
  "error": {
    "message": "An unknown error has occurred.",
    "type": "OAuthException",
    "code": 1,
    "fbtrace_id": "XXXXXXXXXXX"
  }
}

我也尝试使用 c# 脚本

var formDict = new Dictionary<string, string>()
 {
   {"title", "Life"},
   {"type", "testapp:life"},
   {"app_id", "29xxxxxxxxxxxx"}
 };
var formData = new Dictionary<string, string>() { { "object", Facebook.MiniJSON.Json.Serialize(formDict) } };
FB.API("/me?objects/testapp:life", HttpMethod.POST, CreateFBLifeCallback, formData);

并在日志中低于错误,

{"error":{"message":"(#10) Application does not have permission for this action","type":"OAuthException","code":10,"fbtrace_id":"XXXXXXXXXXX"}}

仍然无法创建对象。我应该使用哪种方法来创建对象有点困惑?还是我做错了什么?

帮助将不胜感激。

标签: c#unity3dfacebook-graph-api

解决方案


推荐阅读