1

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;
        }

?>
sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
  • And what you have in error log? – mim. May 06 '15 at 00:36
  • in the chrome console, no error, just a blank line, any idea why I am getting 502 bad gateway? – Rahul Matta May 06 '15 at 00:41
  • i mean php error log, you are writing it with error_log function. If you want to see the error in your page, comment out header line and echo $error. – mim. May 06 '15 at 00:45
  • "couldn't connect to host" – Rahul Matta May 06 '15 at 01:13
  • If you're sure you're able to connect out in general, and it's just Venmo that is the problem, I would [contact Venmo support](https://help.venmo.com/customer/portal/emails/new). – agf May 06 '15 at 21:18

0 Answers0