Facebook C# SDK, AJAX in iFrame app

后端 未结 1 1875
[愿得一人]
[愿得一人] 2021-01-25 09:42

I am making an iFrame application for Facebook using the Facebook C# SDK. I have it that the user is authenticating and I can get their username using the Graph API (FaceBookApp

相关标签:
1条回答
  • 2021-01-25 10:25

    The issue is that with an ajax call in an iframe you must send the session info for the client to the server. Otherwise the FacebookApp has no way of knowing who the current user is. You can solve this in one of two ways.

    1. You can send the entire signed_request value to the server.
    2. You can use the Javascript SDK to get the users access token and send just that value to the server.

    I think the first way is the best. All you need to do is change your ajax url to include the signed request like this:

    var ajaxUrl = '/services/example?signed_request=<%=Request.Querystring["signed_request"] %>';

    Then just make your call like normal with the new url. After that the FacebookApp class will read the session from the ajax request and you will be good to go.

    0 讨论(0)
提交回复
热议问题