2011-01-31 81 views
0

我正在为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来处理这个问题,或者我的选择是什么。

问候, 安德斯·佩特森

回答

0

我有一些问题,Safari浏览器改变HTTP头发送的数据的情况下...确保任何解析/比较你正在做的是不区分大小写。

0

在这里我得到同样的问题,但现在我得到了Safari浏览器的解决方案..

只要改变验证模式在web.config中

<system.web> 

<pages enableViewState="true" validateRequest="false" /> 
<httpRuntime requestValidationMode="2.0"/> 
<!-- 
Enable this code if you get still problem 
<sessionState cookieless="true" regenerateExpiredSessionId="true" />-->