JSON Server

RocketShipIt comes with a built-in JSON server incase you want to communicate with it from other programming languages.

See: Serve.php and Server.php

Parameters are the same as you would find here:

Example Request:

{
    "carrier": "fedex",
    "type": "Rate",
    "action": "getAllRates",
    "parameters": {
        "packages": [

        ],
        "customs": [

        ],
        "key": "YOURKEY",
        "password": "YOURPASS",
        "meterNumber": "YOURMETER"
        "shipper": "RocketShipIt",
        "shipContact": "Mark Sanborn",
        "shipPhone": "7077262676",
        "accountNumber": "510087348",
        "shipAddr1": "201 1\/2 W 2nd St.",
        "shipCity": "Whitehall",
        "shipState": "MT",
        "shipCode": "59759",
        "shipCountry": "US",
        "toCountry": "US",
        "toCode": "90210",
        "service": "GROUND_HOME_DELIVERY",
        "weightUnit": "LB",
        "weight": "17",
        "packagingType": "YOUR_PACKAGING",
        "lengthUnit": "IN",
        "dropoffType": "REGULAR_PICKUP",
        "paymentType": "SENDER",
        "labelFormatType": "COMMON2D",
    }
}

Example Usage

Example:

<?php
require 'lib/autoload.php'; // Path to RocketShipIt autoload.php

// You can send json direct to this php file via system commands
// or through http if you host this file with your webserver.
if (isset($argv)) {
    // Get JSON from argv
    if (count($argv) < 2) {
        echo '{"error": "Invalid request, was it blank?"}';
        exit;
    }

    $input = $argv[1];
} else {
    $input = file_get_contents('php://input');
}

$server = new \RocketShipIt\Server();
echo $server->request($input);

Clients

We currently only have a Ruby and PHP wrapper client available; however, writing up a client should only take an hour or two. If you want to try the Ruby version please shoot us an email.

Using the Ruby client you would simply do:

# Example fetching UPS rate
rate = RocketShipRate.new('UPS')
rate.toCode = 90210
rate.weight = '5'
response = rate.getAllRates()