GetSignedRequest is null if not on the bookmark

I need to access the user's language before requesting any permissions from them. This is usually available in getSignedRequest, but it looks like NULL when I view the application directly, and not on the page tab. So it is NULL when I go to apps.facebook.com/myapp/ , but it has the correct values ​​when I look through it with a page like www.facebook.com/pages/mypage/pageid?sk=appid . Is this a bug or an expected behavior? Should I use a different method when I will not access the application through the page?

+1
source share
2 answers

From what I remember, on Facebook, a signed request will be available only on the first page of your tab - for example. index.php.

Here you will need to save the obtained values ​​and access them from the local storage or session as needed.

Also, if you look at the application directly, it will not be available at all. You must look at it through Facebook for this method to be available. Unfortunately, you need to first request permissions if you want this information outside of the page tab.

Good luck

+4
source

use $ _REQUEST ["signed_request"] for a signed request instead of a function

 $dd = parse_signed_request($_REQUEST["signed_request"]); 

// function for parsing function parse_signed_request ($ signed_request) {list ($ encoded_sig, $ payload) = explode ('.', $ signed_request, 2);

  // decode the data $sig = base64_url_decode($encoded_sig); $data = json_decode(base64_url_decode($payload), true); return $data; } function base64_url_decode($input) { return base64_decode(strtr($input, '-_', '+/')); } 
+1
source

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


All Articles