PHP code example of ajohnson6494 / shippo-php

1. Go to this page and download the library: Download ajohnson6494/shippo-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

ajohnson6494 / shippo-php example snippets


use Shippo\Shippo;

Shippo::setApiKey(env('SHIPPO_API_KEY'));

Shippo::setApiKey(config('services.shippo.key'));

  use Shippo\Shippo;
  use Shippo\Address;

  // Replace <API-KEY> with your Shippo API Key
  Shippo::setApiKey("<API-KEY>");

  $address = Address::create([
    'object_purpose' => 'QUOTE',
    'name' => 'John Smith',
    'company' => 'Initech',
    'street1' => '6512 Greene Rd.',
    'city' => 'Woodridge',
    'state' => 'IL',
    'zip' => '60517',
    'country' => 'US',
    'phone' => '773 353 2345',
    'email' => '[email protected]',
    'metadata' => 'Customer ID 23424'
  ]);

  var_dump($address);