How do I get error details from FBResult in Facebook Unity SDK

天大地大妈咪最大 提交于 2019-12-11 16:35:54

问题


Is there any way to get error details from the FB.API() call in the Facebook Unity SDK? This code

FB.API(
  query: "/me/achievements",
  callback: response => {
    if (!string.IsNullOrEmpty(response.Error)) {
      Logger.LogError("FB ReportProgress Error: " + response.Error);
    } else {
      Logger.Log("FB ReportProgress response: " + response.Text);
    }
  },
  method: Facebook.HttpMethod.POST,
  formData: new Dictionary<string, string>() {{"achievement", url}}
);

logs "400 Bad Request" and nothing else.


回答1:


First you have to enable MonoDevelop's debugger:

  • In MonoDevelop go to the Preferences, then Unity > Debugger
  • Untick "Build project in MonoDevelop" and click OK
  • Run > Attach To Process...
  • Select Unity Editor, click OK

Then, set a breakpoint inside the callback. Select this line in your code and select Run > New Breakpoint...

Logger.LogError("FB ReportProgress Error: " + response.Error);

Then hit Play in Unity and trigger the error (breakpoint). It'll switch to MonoDevelop. Down in the Locals debug window (which should be in a tab somewhere, otherwise View > Debug Windows > Locals) expand the FBResult object. The actual error message (which I assume you're needing) can be found under FBResult > data > responseHeaderString.

More info on MonoDevelop debugging: http://unitygems.com/debugging-game-monodevelop/



来源:https://stackoverflow.com/questions/25538683/how-do-i-get-error-details-from-fbresult-in-facebook-unity-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!