2011-07-28 5 views
0

나는 fb 앱을 만듭니다. FB.ui 메소드 apprequests를 사용하여 내가 보낸 사람에게 친구를 선택하고 벽에 게시하고 싶습니다. 이것은 이렇게 보입니다.

<div id="fb-root"></div> 
<script src="http://connect.facebook.net/pl_PL/all.js" type="text/javascript"></script> 
<script type="text/javascript" > 
FB.init({ 
    appId: myappID, 
    status: true, // check login status 
    cookie: true, // enable cookies to allow the server to access the session 
    xfbml: true, // parse XFBML 
    channelUrl : 'http://localhost:3435/Content/channel.html' 
}); 

function invite(){ 
FB.ui({ method: 'apprequests', 
     message: 'You should learn more about this awesome game.', 
     data: 'tracking information for the user' 
     }, 
function (response) { 

     if (response && response.request_ids) { 
      len = response.request_ids.length; //# of reqs 
      var i = 0; 

      for (i = 0; i < len; i++) { 
      user_req_id = response.request_ids[i]; 
      FB.api('/me/apprequests/?request_ids=' + toString(user_req_id), 
        function (response) { 
        $.post("http://localhost:3435/Home/PostToWall", 
          { request_ids: response['data'][0]['from']['id'] }, 
          function (data) { alert("Data Loaded: " + data); } 
          ); 
        }); 
     } 
    } else { 
     // alert('Post was not published.'); 
    } 
    }) 
    }; 
</script> 

당신이 난이 크롬과 파이어 폭스와 잘 작동하는

[HttpPost, CanvasAuthorize(Permissions = "user_about_me,publish_stream,email")] 
public ActionResult PostToWall(string request_ids) 
{ 
    /* Post to Wall Logic */ 
    return View(); 
} 

에 POST 요청을하고 싶어하지만, IE에서 동작이 해고되지 볼 수 있듯이.

테스트 할 수있는 작은 샘플 자바 스크립트를 준비했습니다. 이것은 문제가있는 곳입니다.

이 FF와 크롬에서 테스트
<script type="text/javascript" > 
    function CallPostToWall() { 
    $.post("http://localhost:3435/Home/PostToWall", 
      { request_ids: 100001968250722 }, 
      function (data) { alert("Data Loaded: " + data);} 
     ); 
    }; 
</script> 
<a href='#' onclick='CallPostToWall()'>Test Posting</a> 

, 경고는 조치를 http://localhost:3435/Home/PostToWall?request_ids=100001968250722 요청한 같은 경우 예상되는 HTML을 반환합니다.

반면에 IE에서는. 나는 다음과 같은 것을 얻는다 :

<html><head><script type="text/javascript"> 
top.location = "http://www.facebook.com/dialog/oauth/?scope=user_about_me,publish_stream,email&state=eyJyIjoiaHR0cDovL2FwcHMuZmFjZWJvb2suY29tL2NoaW5jenlrd3Nvc2llL0hvbWUvUG9zdFRvV2FsbCJ9&client_id=248066421875572&redirect_uri=http://localhost:3435/facebookredirect.axd"; 
</script></head><body></body></html> 

나는 꽤 이것과 함께진다.

의견이 있으십니까?

감사합니다, 사이먼

+0

Google은 사용자 컴퓨터에있는 원인을 테스트 할 수 없으므로 액세스 할 수 없습니다. –

+0

그것이 테스트 코드를 제공 한 이유입니다. 다른 샘플과 함께 사용할 수 있습니다. Facebook-C# -SDK 프로젝트 –

+0

무엇을보고 싶습니까? –

답변

0

아마도 이것은 단지 해결 방법입니다. 나는에 대한 게시물의 몇 가지를 읽은 후 나는 이해로, PostToWall 정의

[HttpPost] 
public ActionResult PostToWall(string request_ids) 
{ 
    /* Post to Wall Logic */ 
    return View(); 
} 

에서 CanvasAuthorize (...) attrinbute를 제거하여 정확한 뷰를 반환 /은 $ .post() 실행을 얻기 위해 관리했습니다 웹은 IE가 "사이트 간 스크립팅"과 같은 동작을 방지함으로써 발생할 수 있습니다.

0

마침내! 'http://mysite.com/api/' : 는 난 그냥에서 URL 매개 변수를 변경했기 때문에 "동일 출처 정책"그냥 IE 내거! : 의 내 문제를 해결 '/ api /' 그리고 작동합니다!

여러분 중 일부를 도울 수 있기를 바랍니다.

관련 문제