php - 在 PHP 中,是否可以将最后一次 curl 尝试的语法作为字符串获取?

标签 php linux curl

偶尔我想通过在Linux终端中运行实际的curl命令来调试curl请求是否可以以字符串格式获取PHP生成的命令来获取curl命令,类似这样?

curl -X PUT \
-H "x-pushbots-appid: 54cc0a511d0ab13c0528b459d" \
-H "x-pushbots-secret: 1444fe8be3324ff7128f25aa18cdee12" \
-H "Content-Type: application/json" \
-d '{ "token" : String ,  "platform" : String ,  "lat" : String ,  "lng" : String ,  "active" : Array ,  "tag" : Array ,  "alias" : String  }' \
https://api.pushbots.com/deviceToken

最佳答案

您需要避免 CLI 执行,因为调试它非常困难。我建议您使用 PHP 的 cURL 扩展 ( http://php.net/manual/en/ref.curl.php ),然后您可以使用以下命令进行调试:

  1. Try-Catch(异常处理)
  2. error_get_last()
  3. function() OR die("---log/Break code --");

关于php - 在 PHP 中,是否可以将最后一次 curl 尝试的语法作为字符串获取?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30152482/

相关文章:

PHP - 验证 recaptcha v2 响应

linux - 删除文件shell脚本

python - 通过python将多个文件组合成一个tar文件

windows - 为什么 CGIHTTPServer 在 Windows 中这么慢?

php - cURL 抓取给我 'Request Rejected' 请求的 URL 被拒绝

php - 如何将 OAuth 与 PHP 和 cURL 结合使用?

php - Woocommerce 产品选项卡的不同状态

PHP Multiselect with Chosen jQuery - 返回所有值而不仅仅是选择的值

php - mysqli动态更新查询

php - 在 PHP 中使 file_get_contents() session 感知