2017 © Pedro Peláez
 

library api-client

A PHP Client for the Picqer API

image

picqer/api-client

A PHP Client for the Picqer API

  • Tuesday, June 5, 2018
  • by cbakker
  • Repository
  • 4 Watchers
  • 8 Stars
  • 16,645 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 20 Versions
  • 12 % Grown

The README.md

Picqer PHP API Client

This project is a PHP Library to use the Picqer API from your PHP application., (*1)

Full documentation for the API can be found on picqer.com/en/api, (*2)

Installation

This project can easily be installed through Composer., (*3)

composer require picqer/api-client

Example: Get orders

<?php

require __DIR__ . '/vendor/autoload.php';

$subDomain = 'jansens-webwinkels';
$apiKey = '1023ihs0edfh';

$apiClient = new Picqer\Api\Client($subDomain, $apiKey);
$apiClient->enableRetryOnRateLimitHit();
$apiClient->setUseragent('My amazing app (dev@example.org)');

$orders = $apiClient->getOrders();
var_dump($orders);

Example: Results generator

If you want to loop trough all your products or orders, you can use the results generator. This will give you the results in a loop as soon as the API returns them. This will also help with memory usage., (*4)

<?php

require __DIR__ . '/vendor/autoload.php';

$subDomain = 'jansens-webwinkels';
$apiKey = '1023ihs0edfh';

$apiClient = new Picqer\Api\Client($subDomain, $apiKey);
$apiClient->enableRetryOnRateLimitHit();
$apiClient->setUseragent('My amazing app (dev@example.org)');

foreach ($apiClient->getResultGenerator('order') as $order) {
    var_dump($order);
}

More examples

Review the examples in the examples/ folder., (*5)

Helpful methods

setUseragent()

It is helpful for us if you set the user agent with the name of the application or developer that build the application. Then we can contact you if we see weird behaviour., (*6)

sendRequest()

This is the main method of the client that sends the API request. If there are new API endpoints that are not yet implemented in this client with dedicated methods, you can create the request yourself with sendRequest()., (*7)

getResultGenerator()

This is a generator for all listing methods like getOrders and getProducts. This will help reduce the memory usage of your application when looping through a lot of orders or products., (*8)

enableDebugmode()

This flag gives you a lot of debug information about the request that the client send and the raw response it got as a result., (*9)

Rate limits

Please keep in mind the rate limit of the Picqer API. In the result array you get a 'rate-limit-remaining' key with the remaining requests you can do in this minute. Try not to make any more requests if this is 0 if you can., (*10)

When you try another request, the request will fail. This client will throw you a RateLimitException. You can catch those and try your request again later., (*11)

We also have an option $apiClient->enableRetryOnRateLimitHit() you can use to enable retry's of requests when you hit a rate limit. When the client hits the rate limit, it will sleep for 20 seconds and try the same request again., (*12)

Webhooks helper

This client also contains a helper for receiving webhooks, including a signature checker. This is included in the PicqerWebhook class., (*13)

To receive a webhook, you only need the following:, (*14)

<?php

require __DIR__ . '/vendor/autoload.php';

$webhook = Picqer\Api\PicqerWebhook::retrieve();

echo 'Hook received: ' . $webhook->getName() . ' that was triggered at ' . $webhook->getEventTriggeredAt() . PHP_EOL;
echo $webhook->getData();

We recommend using signature validation to be sure the webhook was sent by Picqer. Create a hook with a secret, then check the signature of the webhook with that secret as follows:, (*15)

<?php

require __DIR__ . '/vendor/autoload.php';

$webhook = Picqer\Api\PicqerWebhook::retrieveWithSecret('your-secret');

This will throw an WebhookSignatureMismatchException if the secret or signatures do not match., (*16)

Support

Need support implementing the Picqer API? Feel free to contact us, (*17)

The Versions

05/06 2018

dev-master

9999999-dev http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

05/06 2018

v0.14.0

0.14.0.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

29/08 2017

v0.13.3

0.13.3.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

18/08 2017

v0.13.2

0.13.2.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

08/08 2017

v0.13.1

0.13.1.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

02/08 2017

v0.13.0

0.13.0.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

26/11 2015

v0.12.0

0.12.0.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

24/11 2015

v0.11.0

0.11.0.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

13/11 2015

v0.10.0

0.10.0.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

20/04 2015

v0.9.10

0.9.10.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

04/03 2015

v0.9.9

0.9.9.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

08/10 2014

v0.9.8

0.9.8.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

26/08 2014

v0.9.7

0.9.7.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

06/05 2014

v0.9.6

0.9.6.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

23/04 2014

v0.9.5

0.9.5.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

10/04 2014

v0.9.4

0.9.4.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

07/04 2014

v0.9.3

0.9.3.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

10/01 2014

v0.9.2

0.9.2.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

16/10 2013

v0.9

0.9.0.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer

26/08 2013

v0.8

0.8.0.0 http://github.com/picqer/picqer-php

A PHP Client for the Picqer API

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-curl *

 

by Casper Bakker

api php wms picqer