2012-06-13 6 views
0

저는 페이스 북 애플리케이션 (ASP.NET C# 및 Nathan Totten의 Facebook C# SDK 사용)을 개발 중이며 확장 된 권한에 액세스하려고합니다. 페이스 북의 기존 응용 프로그램과 함께 localhost에서 시도했지만 모두 작동합니다. 하지만 페이스 북에서 직접 사용하려고하면 빈 페이지 (나는 여전히 페이스 북에 연결되어 있음)를 얻습니다.C#의 확장 된 사용 권한

페이지/영문 : 내를 Page_Load에서

protected void btn_ask_question_Click(object sender, EventArgs e) 
    { 
     if (ControllerAccess.testUserConnected()) 
     { 
      if (txt_ask_question.InnerText != "") 
      { 
       Dictionary<string, object> action = new Dictionary<string,object>(); 
       action.Add("action", "askQuestion"); 
       action.Add("message", txt_ask_question.InnerText); 
       action.Add("idTheme", ddl_choose_question_category.SelectedValue); 
       HttpContext.Current.Session["ActionToDo"] = action; 
       String s = Controller.GetExtendedPermission2(this, ControllerAccess.getScopeByAction("askQuestion")); 
       try{ 
        Response.Redirect(s, false); 
       } catch(Exception ex) 
       { 
       } 
      } 
     } 
    } 

() : Control.cs에서

if (HttpContext.Current.Session["ActionToDo"] != null) 
      { 
       Dictionary<string, object> action = HttpContext.Current.Session["ActionToDo"] as Dictionary<string, object>; 
       String s = action["action"].ToString(); 
       switch (s) 
       { 
        case "askQuestion": 
         Guid idTheme; 
         Boolean themeExists = Guid.TryParse(action["idTheme"].ToString(), out idTheme); 
         if(themeExists) 
         { 
          askQuestion(action["message"].ToString(), idTheme); 
          lbl_errors.Text = "Votre question a bien été posée"; 
         } 
         break; 
        default: 
         break; 
       } 
       HttpContext.Current.Session["ActionToDo"] = null; 
      } 

: 여기

내 코드입니다

public static string GetCustomOAuthDialogParameters(string AppID, string RedirectURI, string Scope, string State) 
    { 
     string CustomParameters = "?client_id=" + AppID + "&redirect_uri=" + RedirectURI + "&scope=" + Scope + "&state=" + State; 
     return CustomParameters; 
    } 

    public static void GetExtendedPermission(Page page, String scope) 
    { 

     ecritureFichier("GetExtendedPermission"); 
     Label lbl_errors = page.Form.FindControl("lbl_errors") as Label; 
     string OAuthDialogAbsoluteURL = ""; 
     try 
     { 
      string OAuthDialogURL = "https://www.facebook.com/dialog/oauth"; 
      string PageLocation = GetCurrentPageFacebookPublishedPath(page.Request); //The redirect page (eg: https://apps.facebook.com/democsharpsdk/TestsExtendedPermission.aspx) 
      string UniqueReferenceCode = Guid.NewGuid().ToString(); 

      OAuthDialogAbsoluteURL = OAuthDialogURL + GetCustomOAuthDialogParameters(AppID, PageLocation, scope, UniqueReferenceCode); 
      page.Response.Redirect(OAuthDialogAbsoluteURL, false); 
     } 
     catch (Exception exp) 
     { 
      lbl_errors.Text += "Erreur Catchée via ASP.NET : " + exp.Message; 
     } 
    } 

이 l을 사용하면 빈 페이지가 나타납니다. ine : page.Response.Redirect (OAuthDialogAbsoluteURL, false);

는 그러나 나는 내 모든 단계를 기록하고 내 OAuthDialogAbsoluteURL 올바른 것입니다 : 내가 수동으로 ADRESS 표시 줄에 입력하면 모든 것이 제대로 작동

https://www.facebook.com/dialog/oauth?client_id=XXXXXXXXXXXXXXXXX&redirect_uri=https://apps.facebook.com/name_of_my_app&scope=email&state=0443030f-dddd-4fe6-9d6c-9454409d01b3

.

로컬 버전과 게시 된 버전의 차이점이나 리디렉션이 작동하지 않는 이유는 무엇입니까? 어쩌면 facebook이 일부 요청을 차단할 수 있습니까?

감사합니다.

답변

0

나는 결국 내 문제를 해결하기 위해 크롬 디버거를 사용했다.

Refused to display document because display forbidden by X-Frame-Options 

내가 자바 스크립트가 그것을 해결하기 위해 사용되며,이 같은 내 재 지정했다 : 오류는
Response.Write("<script>"); 
Response.Write("window.open('"+redirect+"','_top')"); 
Response.Write("</script>"); 

그것은 어떤 사람들을 도울 것입니다 희망을.

0

다른 환경을 테스트하기 위해 앱을 사용하려면 설정이 호스트 된 버전을 가리키고 있는지 확인하십시오. Facebook은 보안상의 이유로 앱에 연결되지 않은 사이트의 사용자를 인증하도록 허용하지 않습니다.

일반적으로 "URL은 애플리케이션 소유가 아닙니다"또는 이와 유사한 오류가 표시됩니다.

+0

그래서 내가 주소를 보여줍니다. 나는 그것이 정확하고 facebook developper 페이지가 아마도 그것이 좋은 방법이라는 것을 확인한다고 생각합니다. 그래서 나는 내가 뭔가 잘못했는지 알고 싶었다. :). 캐치 메서드에서 로그 메시지가 있지만 아무것도 기록되지 않습니다. 그래서 캐치 ..에 이동하지 않습니다. : / – algelos

관련 문제