Gewusst wie: array von Argumenten, die cURL-Kommandozeile?

Bekam ich die gewünschte Antwort, wenn ich senden cURL bitte meine PHP Skript.

Meine Anforderung ist wie folgt.

$data = array ("[product[name]]" => "nw",
               "[product[handle]]" => 150,
               "[product[interval_unit]]" => "day",
               "[product[interval]]" => 1,
               "[product[price_in_cents]]" => 0,
               "[product[initial_charge_in_cents]]" => 14200,
               "[product[return_url]]" =>"http://mytrial.com/office/selfie/themes/adcampaign/56cee935-185c-4dfs-asdfa-2b6b0ae84a4d",
               "[product[return_params]]" => "id={subscription_id}&customer_id={customer_id})");
$url="http://mytrial.com/office/selfie/themes/adcampaign/346423/products.json";
$ch  = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, 'sdfkjas2kjsd:x');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$res  = curl_exec($ch);
curl_close($ch);       

Es richtig funktioniert. Ich will die gleiche Anfrage in der Befehlszeile.Zuerst habe ich json-kodiertes array und ich habe versucht, mit diesem Befehle

 curl -u sdfkjas2kjsd:x -H Accept:application/json -H Content-Type:application/json -x POST --data product[name]=nw&product[handle]=142&product[interval_unit]=day&product[interval]=1&product[price_in_cents]=0&product[initial_charge_in_cents]=14400&product[return_url]=http:\/\/54.145.218.63\/dev_lpad\/launchpad\/advertisers\/adcampaign\/56cee935-185c-4349-a8a1-2b6b0ae84a4d&product[return_params]={id={subscription_id}&customer_id={customer_id}}  http://mytrial.com/office/selfie/themes/adcampaign/346423/products.json  

Dann bekam ich den Fehler.

Error: Unable to parse request-body

Gibt es eine Möglichkeit, dieses Problem zu lösen?

UPDATE : Die URL hier ist ein dummy-Wert,Eigentlich bin ich versucht zu verbinden mit Chargify API (Recurring billing-Lösung ).

  • -H Content-Type:application/json Warum haben Sie das gesagt?
  • weil ich bin versucht, senden Sie die json-Daten
  • product[name]=nw&product[handle]… schauen nicht aus der Ferne wie JSON
  • Also, wie kann ich dies beheben?
InformationsquelleAutor ARUNBALAN NV | 2016-03-10
Schreibe einen Kommentar