问题
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