EasyPost\Tracker::create_list PHP Method

create_list() public static method

create a list of trackers
public static create_list ( mixed $params = null, string $apiKey = null ) : mixed
$params mixed
$apiKey string
return mixed
    public static function create_list($params = null, $apiKey = null)
    {
        $class = get_class();
        if (!isset($params['trackers']) || !is_array($params['trackers'])) {
            $clone = $params;
            unset($params);
            $params['trackers'] = $clone;
        }
        $requestor = new Requestor($apiKey);
        $url = self::classUrl($class);
        list($response, $apiKey) = $requestor->request('post', $url . '/create_list', $params);
    }

Usage Example

<?php

require_once "../lib/easypost.php";
\EasyPost\EasyPost::setApiKey('cueqNZUb3ldeWTNX7MU3Mel8UXtaAMUi');
$trackers_rep = array();
for ($i = 0; $i < 5; $i++) {
    $tracker = array();
    $tracker["tracking_code"] = "EZ2000000002";
    $tracker["carrier"] = "USPS";
    array_push($trackers_rep, $tracker);
}
$trackers = \EasyPost\Tracker::create_list($trackers_rep);
var_dump($trackers);