在尝试获取用户的付款交易时,我总是遇到错误。
{
"error": {
"message": "An unexpected error has occurred. Please retry your request later.",
"type": "OAuthException",
"code": 2
}
}
我尝试了几种方法:
// approach 1
$response = $app['facebook']->api('/'.$app['user']['fbUserID'].'/payment_transactions', 'GET', [
//'request_id' => $order['requestID'],
'access_token' => $app['fb.app_id'].'|'.$app['fb.app_secret']
]);
// approach 2
$url = 'https://graph.facebook.com/'.$app['user']['fbUserID'].'/payment_transactions?fields=id&access_token='.$app['fb.app_id'].'|'.$app['fb.app_secret'];
$ch = curl_init();
$options = [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_CONNECTTIMEOUT => 10,
CURLOPT_TIMEOUT => 60,
CURLOPT_HTTPHEADER => array('Expect:'),
CURLOPT_CAINFO => DIR.'/vendor/facebook/php-sdk/src/fb_ca_chain_bundle.crt'
];
curl_setopt_array($ch, $options);
$result = curl_exec($ch);
curl_close($ch);
// approach 3
// like 2 but with a fresh access token
$appAccessToken = explode('=', file_get_contents('https://graph.facebook.com/oauth/access_token?client_id='.$app['fb.app_id'].'&client_secret='.$app['fb.app_secret'].'&grant_type=client_credentials'))[1];
即使在 Graph API Explorer 中,我也会收到此错误。只有当我使用命令行时它才有效:
$ curl 'https://graph.facebook.com/........./payment_transactions?access_token=.......|.........'
该用户是一个测试用户,也是一个支付测试者,并且成功地进行了测试购买。禁用本地货币支付重大更改。
我究竟做错了什么?