我正在尝试将我的ASP.NET WebForms IFrame Canvas应用程序从Facbook C#SDK 4.02升级到5.03 beta。大多数变化都相当直接。但是,我对CanvasAuthorizer.GetLoginUrl()并不是100%肯定。
这是我的v4.02代码
CanvasAuthorizer _authorizer = new CanvasAuthorizer {Perms = "publish_stream,offline_access"};
Uri authurl = _authorizer.GetLoginUrl(new HttpRequestWrapper(Request));
CanvasRedirect(authurl.ToString());
根据http://developers.facebook.com/docs/reference/dialogs/oauth上的php示例,这是我对v5.03的最佳猜测
CanvasAuthorizer _authorizer = new CanvasAuthorizer {Perms = "publish_stream,offline_access"};
Dictionary<string, object> parameters =
new Dictionary<string, object>
{
{"scope", _authorizer.Perms},
{"client_id", _authorizer.AppId},
{"redirect_uri", _authorizer.ReturnUrlPath},
{"response_type", "token"}
};
Uri authurl = _authorizer.GetLoginUrl(parameters);
CanvasRedirect(authurl);
这会有用吗?有更好的方法吗?
答案 0 :(得分:0)
经过一些反复试验,我使用以下方法让它工作:
CanvasAuthorizer _authorizer = new CanvasAuthorizer {Perms = "publish_stream,offline_access"};
if (!_authorizer.IsAuthorized())
{
_authorizer.HandleUnauthorizedRequest();
}