PHP code example of namidad / laravel-usps

1. Go to this page and download the library: Download namidad/laravel-usps 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/ */

    

namidad / laravel-usps example snippets


Johnpaulmedina\Usps\UspsServiceProvider::class,

'Usps' => Johnpaulmedina\Usps\Facades\Usps::class,

'usps' => [
		'username' => "XXXXXXXXXXXX",
		'testmode' => false,
	],



namespace App\Http\Controllers;

use App\Http\Requests;
use Illuminate\Support\Facades\Request;
use Johnpaulmedina\Usps;

class USPSController extends Controller
{
    public function index() {
        return response()->json(
            Usps::validate( 
                Request::input('Address'), 
                Request::input('Zip'), 
                Request::input('Apartment'), 
                Request::input('City'), 
                Request::input('State')
            )
        );
    }

    public function trackConfirm() {
        return response()->json(
            Usps::trackConfirm( 
                Request::input('id')
            )
        );
    }

    public function trackConfirmRevision1() {
        return response()->json(
            Usps::trackConfirm( 
                Request::input('id'),
                'Acme, Inc'
            )
        );
    }
}