Facebook web form app gets app_data querystring

How can I get querystring app_data from facebook web form application? I want to be able to send some information to querystring so that I can display different home screens in my application. The application sits on the page tab.

Example: http://www.facebook.com/pages/APPNAME/157772164271503?sk=app_230501256972470&app_data=Page.aspx

How do I get "page.aspx" from app_data? I need to redirect the user to another page from Default.aspx

I have found a solution. Get Querystring from facebook tab app using asp.net

using Newtonsoft.Json.Linq; using System.Text; public partial class Page_Default : System.Web.UI.Page { protected string output = ""; protected void Page_Load(object sender, EventArgs e) { output = "Whole thing:" +Request.Form["signed_request"]; output += "Second part:" + Request.Form["signed_request"].Split('.')[1]; try { string payload = Request.Form["signed_request"].Split('.')[1]; var encoding = new UTF8Encoding(); var decodedJson = payload.Replace("=", string.Empty).Replace('-', '+').Replace('_', '/'); var base64JsonArray = Convert.FromBase64String(decodedJson.PadRight(decodedJson.Length + (4 - decodedJson.Length % 4) % 4, '=')); var json = encoding.GetString(base64JsonArray); var o = JObject.Parse(json); output += "Decoded:" + json; bool liked = (bool)o.SelectToken("page.liked"); output += "Liked:" + liked.ToString(); } catch (Exception ex) { output += "Extract failed: " + ex.Message; } } } 

Also this post was helpful.

just add a direct page to your facebook ex app settings. www.site.com/deafult.aspx not www.site.com

+6
source share
2 answers

In the JSON array that contains facebook posts, one of the top-level keys is app_data, if one is specified. This way you can do it the same way as for your "favorite", but instead of "page.liked" it will just be "app_data" (and not logical)

+3
source

facebook does not send a request to your page. it makes a message on your page from a different URL, so you cannot read the request from the page load. I have not tried this, but you can try to access the .top.location.search window in the js page.

-2
source

Source: https://habr.com/ru/post/892325/


All Articles