-
-
Save christophengelmayer/5147760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/******************************************************** | |
* Usage: | |
* - include this file in any document | |
* - use the following PHP tags to show / hide content: | |
* | |
* <?php if( LIKED ): ?> | |
* Welcome my friend | |
* <?php else: ?> | |
* Please like us | |
* <?php endif; ?> | |
* | |
*******************************************************/ | |
$signed_request = $_REQUEST['signed_request']; | |
function parsePageSignedRequest() | |
{ | |
if ( isset( $_REQUEST['signed_request'] ) ) | |
{ | |
$encoded_sig = null; | |
$payload = null; | |
list($encoded_sig, $payload) = explode('.', $_REQUEST['signed_request'], 2); | |
$sig = base64_decode(strtr($encoded_sig, '-_', '+/')); | |
$data = json_decode(base64_decode(strtr($payload, '-_', '+/'), true)); | |
return $data; | |
} | |
return false; | |
} | |
if( $signed_request = parsePageSignedRequest() ) | |
{ | |
if( $signed_request->page->liked ) | |
{ | |
define( 'LIKED', TRUE ); | |
} | |
else | |
{ | |
define( 'LIKED', FALSE ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment