【问题标题】:Php curl function api [closed]php curl函数api [关闭]
【发布时间】:2016-02-23 21:13:20
【问题描述】:

谁能帮我在php中做一个curl函数来访问这个api服务

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

目前我有这个,但我收到 403 错误

$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);

谢谢

【问题讨论】:

标签: php api curl


【解决方案1】:

去掉CURLOPT_POST使用,curl命令行使用GET。

您使用CURLOPT_USERPWD 设置的字符串不以冒号开头,而您的命令行版本则使用冒号(如使用-u 设置的那样)。

【讨论】:

  • 谢谢,完美运行
猜你喜欢
  • 2017-02-10
  • 2014-02-10
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-05-03
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多