Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(E_ALL);
- ini_set('display_errors', 1);
- require 'vendor/autoload.php';
- use GuzzleHttp\Client;
- $client = new \GuzzleHttp\Client(['headers' => ['API_USERNAME' => 'wandogren', 'API_PASSWORD' => 'aehebpbzcwwg']]);
- $url = "https://www.netparcel.com/shipping_service";
- $ratesRequest = [
- "rate" => [
- "origin" => [
- "country" => "CA",
- "postal_code" => "V3N4R3",
- "province" => "ON",
- "city" => "Burnaby",
- "name" => null,
- "address1" => "90 Maverick",
- "address2" => null,
- "address3" => null,
- "phone" => null,
- "fax" => null,
- "address_type" => null,
- "company_name" => null
- ],
- "destination" => [
- "country" => "CA",
- "postal_code" => "l4j7y9",
- "province" => "ON",
- "city" => "vaughan",
- "name" => "riz mer",
- "address1" => "90 street",
- "address2" => "",
- "address3" => null,
- "phone" => "6479988858",
- "fax" => null,
- "address_type" => null,
- "company_name" => ""
- ],
- "items" => [
- [
- "name" => "My TEST - My PRODUCT",
- "sku" => "12345",
- "quantity" => 1,
- "weight" => 30,
- "weightUnit" => "lbs",
- "price" => 1200,
- "vendor" => "riznetparcel",
- "requires_shipping" => true,
- "taxable" => true,
- "fulfillment_service" => "manual",
- "product_id" => 179093853,
- "variant_id" => 410333945
- ]
- ],
- "packaging_information" => [
- [
- "packaging_type" => "My Packaging",
- "packages" => [
- "length" => 1,
- "width" => 1,
- "height" => 1,
- "weight" => 5,
- "weightUnit" => "lbs",
- "insurance_amount" => 200.00,
- "description" => "Test",
- "freight_class" => "77.5",
- "nmfc_code" => "12345",
- "type" => "pallet"
- ]
- ]
- ]
- ]
- ];
- echo "<pre>";
- print_r(json_encode($ratesRequest));
- echo "</pre>";
- $postRequest = $client->post( $url, ['body' => json_encode($ratesRequest)] );
- $postStatusCode = $postRequest->getStatusCode();
- $postReason = $postRequest->getReasonPhrase();
- $postResponse = $postRequest->getBody();
- echo "Get Status code: " . $postStatusCode . "<br>";
- echo "Reason:" . $postReason . "<br>";
- $stringBody = (string) $postResponse;
- echo $stringBody;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement