رتبه موضوع:
  • 0 رای - 0 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
ارسال json به وب سرویس rest
#1
با سلام خدمت شما

داده json زیر را میخوام از طریق CURL یا ... به یک وب سرویس از نوع REST ارسال کنم .
لطفا بگید این دیتا را از طریق POST به چه صورت در CURL قرار بدم . ممنون از شما

Data

کد:
{
"customerNumber":null,
"merchantNumber":null,
"terminalNumber":null,
"ExportTo":0,
"serviceColumns":[
    {
          "filterTitle":"تاریخ اول","filterType":60,"conditionType":32,"conditionValue":"1398/07/01","columnKey":"stracedt","columnName":"STraceDt","isMandatory":true,"FixedValue":null
    },{
          "filterTitle":"تاریخ دوم","filterType":60,"conditionType":22,"conditionValue":"1398/07/09","columnKey":"stracedt","columnName":"STraceDt","isMandatory":true,"FixedValue":null
    },{
          "filterTitle":"شماره","filterType":0,"conditionType":0,"conditionValue":"","columnKey":"pan","columnName":"Pan","isMandatory":false,"FixedValue":null
   },{
          "filterTitle":"پیگیری","filterType":0,"conditionType":0,"conditionValue":"","columnKey":"rrn","columnName":"RRN","isMandatory":false,"FixedValue":null
   },{
         "filterTitle":"مبلغ اول","filterType":50,"conditionType":32,"conditionValue":"","columnKey":"originalamount","columnName":"OriginalAmount","isMandatory":false,"FixedValue":null
   },{
         "filterTitle":"مبلغ دوم","filterType":50,"conditionType":22,"conditionValue":"","columnKey":"originalamount","columnName":"OriginalAmount","isMandatory":false,"FixedValue":null
  }
],
"UserName":"remp",
"Password":"K0ec0264d81ecb443c55623a64e5I=",
"RepWebserviceKey":"4f22779572c8193180cf1530330ec25b",
"CustomerKey":"723bcf136c3ea1029591aae9c74b",
"RepRelationKey":"0e82371a86c9b61f7ba532e7876acdb9",
"CanSplitFun":false,
"OfsetCount":-1,
"FetchCount":-1
}


CURL

$data = array(

/////////////////
);
$payload = json_encode($data);

// Prepare new cURL resource
$ch = curl_init('https://test.com');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);

// Set HTTP Header for POST request 
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
   'Content-Type: application/json',
   'Content-Length: ' . strlen($payload))
);

$result = curl_exec($ch);
curl_close($ch);
پاسخ
تشکر شده توسط:




کاربران در حال بازدید این موضوع: 2 مهمان