我正在为Facebook建立一个Iframe画布应用程序。我没有使用Javascript SDK。Facebook的C#SDK - Iframe应用程序和Safari Cookies的问题
这是我正在使用的代码,并且它在除Safari之外的所有浏览器中都能正常工作。
protected FacebookApp app;
protected CanvasAuthorizer cauth; Response.AddHeader(“p3p”,“CP = \”IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT \“”); app = new FacebookApp(); cauth = new CanvasAuthorizer(app);如果(!cauth.IsAuthorized()) { myAuth auth = new myAuth(); myAuth.Authorize(app,Request,Response,perms); }
if (cauth.Authorize())
{
//在这里做 我的应用程序的东西}
public class myAuth
{
public static void Authorize(FacebookApp fbApp, System.Web.HttpRequest request, System.Web.HttpResponse response, string perms)
{
Authorize(fbApp, request, response, perms, null);
}
public static void Authorize(FacebookApp fbApp, System.Web.HttpRequest request, System.Web.HttpResponse response, string perms, string redirectUrl)
{
Uri url = fbApp.GetLoginUrl();
NameValueCollection nvc = System.Web.HttpUtility.ParseQueryString(url.Query);
if (!string.IsNullOrEmpty(perms))
nvc.Add("req_perms", perms);
if (!string.IsNullOrEmpty(redirectUrl))
nvc["next"] = GetAppRelativeUrl(redirectUrl);
else if (request.QueryString.Count > 0)
nvc["next"] = GetAppRelativeUrl(request.Path.Replace(request.ApplicationPath, string.Empty).Replace(request.ApplicationPath.ToLower(), string.Empty) + "?" + request.QueryString);
else
nvc["next"] = GetAppRelativeUrl(request.Path.Replace(request.ApplicationPath, string.Empty).Replace(request.ApplicationPath.ToLower(), string.Empty));
UriBuilder ub = new UriBuilder(url);
ub.Query = nvc.ToString();
string content = CanvasUrlBuilder.GetCanvasRedirectHtml(ub.Uri);
response.ContentType = "text/html";
response.Write(content);
response.End();
}
public static string GetAppRelativeUrl(string url)
{
return CanvasSettings.Current.CanvasPageUrl.ToString();
}
}
我读到有关Safari不允许第三方Cookie,而且我想这就是问题所在。我的问题是有没有办法使用SDK来处理这个问题,或者我的选择是什么。
问候, 安德斯·佩特森