我一直在无情地尝试使用 venmo api 的支付端点来从 oauthed 用户那里进行支付。用户可以通过 venmo 进行授权——我收到了一个访问令牌。以下 PHP 文件可识别令牌,但当脚本执行时,我收到 502 bad gateway 错误。
谁能帮忙
<?php
# Our new data
$data = array(
'access_token' => $_POST['token'],
'note' => 'Ticket',
'amount' => "1.0",
'email' => "email@email.com"
);
# Create a connection
$url = 'https://api.venmo.com/v1/payments';
$header = array(
'Authorization: Bearer ' . $_POST['token'],
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
$response = curl_exec($ch);
$error = curl_error($ch);
if ($error != '')
{
error_log('Curl error: ' . $error);
header('HTTP/1.0 502 Bad Gateway', true, 502);
exit;
}
else
{
return $response;
}
?>