我一次又一次地收到以下错误..我无法弄清楚出了什么问题!我所做的只是从developers.facebook.com 复制并粘贴代码,并更改了我为这些问题划掉的应用程序ID 和fb secrey 密钥!
错误是:
错误请求 您的浏览器发送了此服务器无法理解的请求。请求头字段的大小超过服务器限制。推荐人/n
代码如下:
<?php
define('FACEBOOK_APP_ID', 'xxxxx');
define('FACEBOOK_SECRET', '2ab5cxxxxxxxxxx89a');
function parse_signed_request($signed_request, $secret) {
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);
if (strtoupper($data['algorithm']) !== 'HMAC-SHA256') {
error_log('Unknown algorithm. Expected HMAC-SHA256');
return null;
}
// check sig
$expected_sig = hash_hmac('sha256', $payload, $secret, $raw = true);
if ($sig !== $expected_sig) {
error_log('Bad Signed JSON signature!');
return null;
}
return $data;
}
function base64_url_decode($input) {
return base64_decode(strtr($input, '-_', '+/'));
}
if ($_REQUEST) {
echo '<p>signed_request contents:</p>';
$response = parse_signed_request($_REQUEST['signed_request'],
Facenook_Secret);
echo '<pre>';
print_r($response);
echo '</pre>';
} else {
echo '$_REQUEST is empty';
}
?>