You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

将含数组参数的PHP POST cURL请求转换为cURL命令行

Convert PHP cURL POST to Command-Line cURL

Got it, let's turn your PHP array-based POST request into a usable command-line cURL command. I'll break this down clearly for you:

Step 1: Map the PHP Array to JSON Payload

Since your data includes a nested price sub-array, using JSON is the cleanest approach (it mirrors the PHP array structure perfectly). Here's the equivalent JSON:

{
  "vehicleClass": "Car",
  "category": "Van",
  "make": "RENAULT",
  "model": "Scenic",
  "modelDescription": "Turbopoooower",
  "firstRegistration": "201606",
  "mileage": "500",
  "damageUnrepaired": true,
  "condition": "USED",
  "internalNumber": "12",
  "price": {
    "consumerPriceGross": "5400"
  }
}

Step 2: Full cURL Command

Here's the complete command-line cURL call that matches your PHP code. I've included placeholders for your proxy and auth values, plus notes on what to adjust:

curl -X POST \
  -H "Content-Type: application/json" \
  --proxy PROXY_MOBILE_DE:PROXY_PORT_MOBILE_DE \
  --proxy-user LOGINPASSWD_MOBILE_DE \
  -d '{
    "vehicleClass": "Car",
    "category": "Van",
    "make": "RENAULT",
    "model": "Scenic",
    "modelDescription": "Turbopoooower",
    "firstRegistration": "201606",
    "mileage": "500",
    "damageUnrepaired": true,
    "condition": "USED",
    "internalNumber": "12",
    "price": {
      "consumerPriceGross": "5400"
    }
  }' \
  https://your-target-api-url.com

Key Details to Adjust:

  • Replace https://your-target-api-url.com with the actual URL you're sending the request to.
  • If your LOGINPASSWD_MOBILE_DE is in the format username:password, it'll work directly with --proxy-user. If not, adjust it to match your proxy's auth requirements.
  • If you're using environment variables for proxy values (like in your PHP code), you can swap them in directly (e.g., $PROXY_MOBILE_DE instead of the literal string).

Alternative: Form-Encoded Data (If Required)

If the API expects application/x-www-form-urlencoded instead of JSON, you'd format the data like this (note how nested arrays use bracket notation):

curl -X POST \
  --proxy PROXY_MOBILE_DE:PROXY_PORT_MOBILE_DE \
  --proxy-user LOGINPASSWD_MOBILE_DE \
  -d 'vehicleClass=Car' \
  -d 'category=Van' \
  -d 'make=RENAULT' \
  -d 'model=Scenic' \
  -d 'modelDescription=Turbopoooower' \
  -d 'firstRegistration=201606' \
  -d 'mileage=500' \
  -d 'damageUnrepaired=true' \
  -d 'condition=USED' \
  -d 'internalNumber=12' \
  -d 'price[consumerPriceGross]=5400' \
  https://your-target-api-url.com

But JSON is almost always better for nested data structures like yours, so I'd stick with the first option unless the API specifically requires form-encoded data.

内容的提问来源于stack exchange,提问作者denimb

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 08:27:38