I have been relentlessly trying to use the payments endpoint of the venmo api to be able to make a payment from an oauthed user. The user is able to authorize through venmo -- I receive an access token back. The following PHP file recognizes the token, but when the script executes, I get a 502 bad gateway error.
Can anyone help
<?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;
}
?>