Facebook fan page app pass string to app_data and retrieve

ぃ、小莉子 提交于 2019-12-05 08:07:10

问题


Hi i have a multiple page facebook fan page app in asp.net c#. how do i set and retrieve that app_data querystring? is this part of the signedrequest or the actual url of the fan page? will there be cross domian issues in getting this in safari and ie?

i can get the signed_request using the following:

 if (!string.IsNullOrEmpty(signedRequest))
{
    dynamic SignedRequestData;
    var DecodedSignedRequest = FacebookWebContext.Current.SignedRequest.Data;
    SignedRequestData = DecodedSignedRequest

so basically on the first page i want to get the signed_reqeuest using the above and then append this to the url in app_data querystring. on all other requests i can then get this and use those values to check user status, liked, logged in etc. This way i think it will stop the cross domain cookie issues in safari. anyone agree or disagree with this?

has anyone done this?

cheers


回答1:


You can set the app_data as:

https://www.facebook.com/{page_id}?sk=app_{app_id}&app_data={"key1":"value1","key2":"value2"}

You can pass multiple values into app_data and it will be returned in the signed_request to your actual page as (POST data).

What you should really do is get the signed_request on first page load from POST, and add it to the URL of your app as ...?signed_request={signed_request_string}. Every page should then pass this around in the URL so you can easily check the like and admin status from any sub-page. You don't need to use app_data for this. And in any case, the data will be lost after the any subsequent click / redirect in your app.



来源:https://stackoverflow.com/questions/10801807/facebook-fan-page-app-pass-string-to-app-data-and-retrieve

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!