Giter Club home page Giter Club logo

karrio-php's Introduction

This repository is not maintained anymore. Chat with us if you want to help maintain a PHP client for Karrio at https://github.com/karrioapi/karrio

Karrio PHP Client

karrio is a universal Shipping API that simplifies the integration of logistic carrier services.

Visit karrio.io to deploy your private cloud multi-carrier shipping API.

Documentation

See the full PHP API docs.

Requirements

PHP 5.5 and later

Installation & Usage

Composer

To install the bindings via Composer, add the following to composer.json:

composer require karrio/karrio-php

Development

composer install

Usage

Please follow the installation procedure and then run the following:

<?php
require_once(__DIR__ . '/vendor/autoload.php');

// Configure API key authorization: Token
$karrio = new \Karrio\Karrio('YOUR_API_KEY', 'https://api.karrio.io');

try {
    $result = $karrio->carriers->list();
    print_r($result);
} catch (Exception $e) {
    echo 'Exception when calling carriers->list: ', $e->getMessage(), PHP_EOL;
}

?>

Documentation For Models

Models

Author

Team Karrio | [email protected] | karrio.io

karrio-php's People

Contributors

danh91 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

karrio-php's Issues

Custom Carrier

Hello,

Can this be used for custom carrier or do they have to be registered with the service?

Unable to track package with Canada Post

I setup the demo docker container + input my Canada Post api credentials into the admin portal.

Verified that I could get the list of carriers through purplship-php-client, with canadapost being returned as a possible carrier.
Array ( [0] => PurplShip\Model\CarrierSettings Object ( [container:protected] => Array ( [id] => car_0398f1e898bb4f558cdac1851b6772ed [carrier_name] => canadapost [carrier_id] => canadapost [test] => ) ) )

But when I try to track a package, I get the following error:

Exception when calling Tracking->fetch: [404] Client error: GET http://.com:8010/v1/proxy/tracking/canadapost/********?test=resulted in a404 Not Foundresponse: {"error":{"message":"No configured carrier of type: canadapost"}}

Problem tracking with USPS

Using your previous example, I'm able to track UPS deliveries just fine, however when I try to track a USPS package, I get the following error:

Exception when calling trackers->create: [500] Server error: `GET https://cloud.purplship.com/v1/trackers/usps/9400111899220892111111?test=0` resulted in a `500 Internal Server Error` response:
{"error":{"message":"'NoneType' object has no attribute 'org'"}}

Any idea what's wrong?

The code I'm using is very simple:

<?php

  require_once(__DIR__ . '/vendor/autoload.php');

  $shipper = 'usps';
  $tracking_number = '9400111899220892111111';

 // Configure API key authorization: Token
  $purplship = new \Purplship\Purplship('YOUR_API_KEY', 'https://cloud.purplship.com');

  try {
    $result1 = $purplship->trackers->create($shipper, $tracking_number);
    print_r($result1);
  }
  catch (Exception $e) {
    echo 'Exception when calling trackers->create: ', $e->getMessage(), PHP_EOL;
  }

Thanks

Tracking Example Needed

Hello,

Would you be willing to provide an example on how to track a package? I've hit a wall. I modified your sample code as follows:

<?php

	require_once(__DIR__ . '/vendor/autoload.php');

  // Configure API key authorization: Token
	$purplship = new \Purplship\Purplship('YOUR_API_KEY', 'https://cloud.purplship.com');

	try {
		$result = $purplship->trackers->retrievesRequest('1Z1234567899999999');
		print_r($result);
	}
	catch (Exception $e) {
		echo 'Error when retrieving tracking info: ', $e->getMessage(), PHP_EOL;
	}

but I can't get it to return the status. This is what it returns:

GuzzleHttp\Psr7\Request Object
(
    [method:GuzzleHttp\Psr7\Request:private] => GET
    [requestTarget:GuzzleHttp\Psr7\Request:private] => 
    [uri:GuzzleHttp\Psr7\Request:private] => GuzzleHttp\Psr7\Uri Object
        (
            [scheme:GuzzleHttp\Psr7\Uri:private] => https
            [userInfo:GuzzleHttp\Psr7\Uri:private] => 
            [host:GuzzleHttp\Psr7\Uri:private] => cloud.purplship.com
            [port:GuzzleHttp\Psr7\Uri:private] => 
            [path:GuzzleHttp\Psr7\Uri:private] => /v1/trackers/1Z1234567899999999
            [query:GuzzleHttp\Psr7\Uri:private] => 
            [fragment:GuzzleHttp\Psr7\Uri:private] => 
        )

    [headers:GuzzleHttp\Psr7\Request:private] => Array
        (
            [Host] => Array
                (
                    [0] => cloud.purplship.com
                )

            [User-Agent] => Array
                (
                    [0] => OpenAPI-Generator/1.0.0/PHP
                )

            [Accept] => Array
                (
                    [0] => application/json
                )

            [Content-Type] => Array
                (
                    [0] => application/json
                )

            [Authorization] => Array
                (
                    [0] => Token key_kj4k4gkjh4kjh4hg4hjjh4v
                )

        )

    [headerNames:GuzzleHttp\Psr7\Request:private] => Array
        (
            [user-agent] => User-Agent
            [accept] => Accept
            [content-type] => Content-Type
            [authorization] => Authorization
            [host] => Host
        )

    [protocol:GuzzleHttp\Psr7\Request:private] => 1.1
    [stream:GuzzleHttp\Psr7\Request:private] => 
)

Thank you.

Composer packages outdated - Missing DocumentsApi

When working with karrio using the composer package https://packagist.org/packages/karrio/karrio-php
the package does not include DocumentsApi. Looks like it has not been re-generated for a while.

I was able to generate for myself.

Be aware that script.sh needs to be updated. Api-Spec is at
https://raw.githubusercontent.com/karrioapi/karrio/main/server/schemas/openapi.yml now.

I had to generate using local npm install.
Docker gave following error:
env: can't execute 'bash': No such file or directory

Great project!
Best regards!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.