convert ajax request with php

i want to convert javascript ajax request json to php, here is what i get from provider write with javascript

   var API_URL = 'api url';
    var header = { 'clientkey': 'key' };
    var data = {
    "origin": "city",
    "OriginZipCode" : "postcode",
    "destination": "city",
    "DestinationZipCode" : "postcode",
    "isInsured": false,
    "itemValue": 18500,
    "items": [
            "weight": 1.2,
            "height": 10,
            "width": 10,
            "length": 10,
              "packagingCode": "BOX001",
              "packagingQty": 2
            "weight": 1.7,
            "height": 10,
            "width": 10,
            "length": 10

    url: API_URL,
    type: 'POST',
     crossDomain: true,
     dataType: 'json',
     data: JSON.stringify(data),
    headers: header,
    success: function (response) {console.log(response); },
   error: function (response) {console.log(response); }

how to change it to php maybe with curl

thank you before

Read more here:

Content Attribution

This content was originally published by finda at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: