1. Go to this page and download the library: Download spiderrobb/signed-request library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spiderrobb / signed-request example snippets
// File that is encoding Signed Request
// ------------------------------------
// defining secret to encode data with
$mySecret = '[My Super Secret String]';
// defining data to encode in signed request
// Note: myData does not need to be an array, it can be an Array, String, Boolean... etc.
$myData = array(
'dataKey' => 'dataValue'
);
$mySR = SignedRequest::encode(
$myData, array('secret' => $mySecret)
);
// File That is decoding Signed Request
// ------------------------------------
// defining secret to decode data with
$mySecret = '[My Super Secret String]';
// decoding signed request
try {
// decoding signed request using same secret
$myData = SignedRequest::decode(
$mySR, array(
'secret' => $mySecret
)
)
print_r($myData);
} catch (Exception $e) {
// signed request has been malformatted or cannot be trusted
var_dump($e);
}
/* output
Array(
'dataKey' => 'dataValue'
)
*/
$mySecret = '[My super secret secret]';
$myData = array(
'dataKey' => 'dataValue'
);
$mySR = SignedRequest::encode(
$myData, array(
'secret' => $mySecret,
'timeout' => 3600 // signed request will expire in 1 hour
)
);
$myData = array(
'id' => 153
);
$myData = array(
'id' => 351
);
// Encoding data in signed request using method attribute
$mySecret = '[My super secret secret]';
$myData = array(
'dataKey' => 'dataValue'
);
$mySR = SignedRequest::encode(
$myData, array(
'method' => 'object1',
'timeout' => 3600 // signed request will expire in 1 hour
)
);
// Decoding data in signed request using method attribute
try {
// decoding signed request using same secret
$myData = SignedRequest::decode(
$mySR, array(
'method' => 'object1',
'secret' => $mySecret
)
)
print_r($myData);
} catch (Exception $e) {
// signed request has been malformatted or cannot be trusted
var_dump($e);
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.