签名请求 - 我如何找到Facebook用户是否喜欢我的fb应用程序?

时间:2012-01-13 08:04:33

标签: request facebook-apps signed

我正在尝试查找用户是否喜欢我的Facebook应用程序,并且我使用此功能:

 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, '-_', '+/'));
}    

$decodedSR = parse_signed_request($_REQUEST['signed_request'],$config['secret']);

//print_r($decodedSR ); 

if ($decodedSR['page']['liked'] == 1) {//code}

问题是此代码(print_r($decodedSR );)返回此数组(没有['page'] ['likes']):

Array ( [algorithm] => HMAC-SHA256 [expires] => 0 [issued_at] => xxx[oauth_token] => xxxxxx[user] => Array ( [country] => xx [locale] => xx [age] => Array ( [min] => 21 ) ) [user_id] => xxxxx) 

我该怎么办?

0 个答案:

没有答案