php - Seamless way to check if user likes page -


So, I'm using an iframe on my tab and I am doing the same as "" barriers where What is a better and more intuitive way to do this, like the page to see the secret content the user should ask for permission?

I know for tabs created with FBML, they do not ask for permission, but I'm guessing because it is not a IFRAME.

Thank you!

Of course you can! As you have said, Facebook will send you some extra details in signed_request :

when a user visits the Facebook page, they will include your page tab in The next available tab position is broadly loaded as a canvas page, when a user selects your page tab, you will get the sign_request parameter with an additional parameter, page. This parameter contains a JSON object with ID (the page ID of the current page), the administrator (if the user is the admin of the page), and it is preferred (the user liked the page). With a canvas page, as long as the user does not authorize your app, you will not have all the user information available for your app in sign-in.

The code taken from me should be something like this:

  & lt ;? Php if (empty ($ _ request ["signed_screated"])) {/ / No signed request was found which means that 1 / 1- This page was not accessed through the Facebook page tab. 2- A redirection was made, so the request is lost "Sign-in-diction not found!"; } And {$ app_secret = "APP_SECRET"; $ Data = parse_signed_request ($ _ request ["signed_cooked"], $ app_secret); If (empty ($ data ["page"] ["likes"])) {resonant "you are not a fan!"; } Else {echo "welcome back fan!"; }} Function parse_signed_request ($ sign_request, $ secret) {list ($ encoded_sig, $ payload) = explosion ('.', $ Signed_compiled, 2); // data $ sig = base64_url_decode ($ encoded_sig) decode; $ Data = json_decode (base64_url_decode ($ payload), true); If (stratouper ($ data ['algorithm'] == 'HMAC-SH256') {error_log ('unknown algorithm. Expected HMAC-SH 256'); return tap;} // check sig $ expected_sig = hash_hammak (' Sha256 ', $ payload, $ secret, $ raw = true; if ($ sig! == $ expected_sig) {error_log (' Bad signature JSON sign! '); Return tap;} Return $ data;} function base64_url_decode ($ Input) {return base64_decode (strter ($ input, '-_', '+ /'));}? & Gt;   

updated code: The last code will work I request valid There was no checking which means that someone can tamper the request and send you false information ( like admin to true ! ). After the approach the code has been updated.

Comments