Advertisement
Guest User

ferffr

a guest
Oct 29th, 2018
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. <?php
  2.  
  3. ini_set('display_errors', 1);
  4. ini_set('display_startup_errors', 1);
  5. error_reporting(E_ALL);
  6. mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX);
  7.  
  8. $url = "https://staging.ekartlogistics.com/v2/shipments/create";
  9.  
  10. $data1 = array
  11. (
  12. "request_id"=> "835",
  13. "client_name"=> "DOC",
  14. "services"=> [
  15. array (
  16. "service_code"=> "REGULAR",
  17. "service_details"=> [
  18. array (
  19. "service_leg"=> "FORWARD",
  20. "service_data"=> array (
  21. "vendor_name"=>"Ekart",
  22. "amount_to_collect"=> 1000,
  23. "dispatch_date"=> "",
  24. "customer_promise_date"=> "",
  25. "delivery_type"=> "SMALL",
  26. "source"=> array (
  27. "address"=> array (
  28. "first_name"=> "AVThamizhmahan",
  29. "address_line1"=> "31675 ES Garden Vazhudaretty Post Villupuram",
  30. "address_line2"=> "Tamil Nadu",
  31. "pincode"=> "560034",
  32. "city"=> "Villupuram",
  33. "state"=> "Tamil Nadu",
  34. "primary_contact_number"=> "88888888"
  35. )
  36. ),
  37. "destination"=> array (
  38. "address"=> array (
  39. "first_name"=> "AVThamizhmahan",
  40. "address_line1"=> "31675 ES Garden Vazhudaretty Post Villupuram",
  41. "address_line2"=> "Tamil Nadu",
  42. "pincode"=> "110037",
  43. "city"=> "Villupuram",
  44. "state"=> "Tamil Nadu",
  45. "primary_contact_number"=> "88888888"
  46. )
  47. ),
  48. "return_location"=> array (
  49. "address"=> array (
  50. "first_name"=> "AVThamizhmahan",
  51. "address_line1"=> "31675 ES Garden Vazhudaretty Post Villupuram",
  52. "address_line2"=> "Tamil Nadu",
  53. "pincode"=> "110037",
  54. "city"=> "Villupuram",
  55. "state"=> "Tamil Nadu",
  56. "primary_contact_number"=> "88888888"
  57. )
  58. )
  59. ),
  60. "shipment"=> array (
  61. "client_reference_id"=> "ABCD",
  62. "tracking_id"=> "DOCC0000000001",
  63. "shipment_value"=> 2000,
  64. "shipment_dimensions"=> array (
  65. "length"=> array (
  66. "value"=> 1
  67. ),
  68. "breadth"=> array (
  69. "value"=> 1
  70. ),
  71. "height"=> array (
  72. "value"=> 1
  73. ),
  74. "weight"=> array (
  75. "value"=> 1
  76. )
  77. ),
  78. "return_label_desc_1"=> "",
  79. "return_label_desc_2"=> "",
  80. "shipment_items"=> [
  81. array (
  82. "product_id"=> "134883075",
  83. "item_content"=>array (),
  84. "category"=> "Apparel",
  85. "product_title"=> "Mast&HarbourBlackHandbag=> Handbags",
  86. "quantity"=> 1,
  87. "cost"=> array (
  88. "total_sale_value"=> 500,
  89. "total_tax_value"=> 100 ,
  90. "tax_breakup"=>array (
  91. "cgst"=>0.0,
  92. "sgst"=>0.0,
  93. "igst"=>0.0
  94. )
  95. ),
  96. "seller_details"=> array (
  97. "seller_reg_name"=> "Seller Registered Legal Name",
  98. "vat_id"=> "",
  99. "cst_id"=> "",
  100. "tin_id"=>"",
  101. "gstin_id"=>""
  102. ),
  103. "hsn" =>"",
  104. "ern"=>"",
  105. "discount"=>0.0,
  106. "legal_entity"=> "",
  107. "billable_entity"=> "",
  108. "cod_remittance_entity"=> "",
  109. "item_attributes"=> [
  110. array (
  111. "name"=> "order_id",
  112. "value"=> "ABCD"
  113. ),
  114. array (
  115. "name"=> "invoice_id",
  116. "value"=> "INV1234"
  117. ),
  118. array (
  119. "name"=> "item_dimensions",
  120. "value"=> "l=>b=>h=>w"
  121. ),
  122. array (
  123. "name"=> "brand_name",
  124. "value"=> "Peter England"
  125. )
  126. ],
  127. "handling_attributes"=> [
  128. array (
  129. "name"=> "isFragile",
  130. "value"=> "false"
  131. ),
  132. array (
  133. "name"=> "isDangerous",
  134. "value"=> "false"
  135. )
  136. ]
  137. )
  138. ]
  139. )
  140. )
  141. ]
  142. )
  143. ]
  144. );
  145.  
  146. echo $data=json_encode($data1);
  147. //$data_string = json_encode(array(
  148. // "Payload" => $data
  149. //));
  150. $username = "";
  151. $password = "";
  152. $ch = curl_init();
  153. curl_setopt($ch, CURLOPT_URL, $url);
  154. curl_setopt($ch, CURLOPT_POST, 1);
  155. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  156. curl_setopt($ch, CURLOPT_HEADER, true);
  157. //curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  158. //
  159. //));
  160. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  161. "Authorization : ZGFpbHlvcmRlcnM6ZHVtbf4fsww=", "Content-Type : application/json"
  162. ));
  163. curl_setopt($ch, CURLOPT_USERPWD, "dailyorders:dummyKey");
  164. curl_setopt($ch, CURLOPT_POST, 1);
  165. curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //play around with json_encode($data) and http_build_query
  166. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  167.  
  168. $return = curl_exec($ch);
  169.  
  170. curl_close ($ch);
  171.  
  172. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement