-2

Can someone help me make a curl function in php to access this api service

curl -v -u :xxxxx-2573-440e-8adc-cc23bb019db9 
https://api.paylike.io/transactions/56ccbfe1b31be55xxxxx

currently I have this but I get 403 error

$ch = curl_init();
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_URL, "https://api.paylike.io/transactions/556ccbfe1b31be55xxxxx");
curl_setopt($ch, CURLOPT_USERPWD, 'xxxxx-2573-440e-8adc-cc23bb019db9');
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type:application/json", "Cache-Control:no-cache"));
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
curl_close($ch);

Thanks

Err
  • 890
  • 2
  • 11
  • 32
  • Possible duplicate of http://stackoverflow.com/questions/8540800/php-how-can-use-curl-instead-file-get-contents – Matt Feb 23 '16 at 21:23

1 Answers1

0

Remove the CURLOPT_POST use, the curl command line uses GET.

The string you set with CURLOPT_USERPWD doesn't start with a colon, which your command line version does (as set with -u).

Daniel Stenberg
  • 54,736
  • 17
  • 146
  • 222