问题
I'm trying to create a FB credits callback page, and need to parse the signed request coming in. I can write something manually, but it seems like this is something that should be in the SDK somewhere but I can't seem to find it in the API.
回答1:
Simply call the static method Parse
on the FacebookSignedRequest
class as shown below (with your app secret, and the signed request):
var DecodedSignedRequest = FacebookSignedRequest.Parse(FacebookContext.Current.AppSecret, SignedRequest);
Now you will see all the data (in JSON format) from the signed request in DecodedSignedRequest
.
回答2:
Starting from v6:
var fb = new FacebookClient();
dynamic signedRequest = fb.ParseSignedRequest("app_secret", Request.Params["signed_request"]);
来源:https://stackoverflow.com/questions/5481669/how-do-i-parse-a-signed-request-in-facebook-c-sharp-sdk