Skip to content

Instantly share code, notes, and snippets.

@madiodio
Last active December 28, 2018 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save madiodio/ab3168dd93417d69055e68f7eccb004b to your computer and use it in GitHub Desktop.
Save madiodio/ab3168dd93417d69055e68f7eccb004b to your computer and use it in GitHub Desktop.
<?php
// Guzzle est supposé déjà être chargé avec le vendor/autoload.php
// Initialiser le Client avec GuzzleHttp
$client = new GuzzleHttp\Client();
// Pour avoir les informations sur une tâche donnée dont l' ID de la tâche est 22792852
$client->request('GET', 'https://api.paps.sn/v1/viewTask', [
'query' => ['apiKey' => '69bd76dc74ca1d0834de769e3947481a25a9389fc2e172ab1c33', 'id' => '22792852']
]);
// Envoyer une requête pour créer une nouvelle commande ramassage (utiliser createDelivery s'il s'agit d'une livraison)
// Se référer à la documentation pour les paramètres d'envoi des requêtes (https://developers.paps.sn/create)
$response = $client->request('POST', 'https://api.paps.sn/v1/createPickup', [
'headers' => [
'Content-Type' => 'application/json'
]
'query' => ['apiKey' => '69bd76dc74ca1d0834de769e3947481a25a9389fc2e172ab1c33']
'body' => '{"jobPickupAddress": "Fann Hock, Dakar, Sénégal", "timezone": "0", "jobDeliveryDatetime": "2018-12-24 01:00:00"}'
]);
// Pour connaitre la réponse sur la commande créée
echo $response;
<?php
// Sans Guzzle
$request = new HttpRequest();
$request->setUrl('https://api.paps.sn/v1/createPickup');
$request->setMethod(HTTP_METH_POST);
$request->setQueryData(array(
'apiKey' => '69bd76dc74ca1d0834de769e3947481a25a9389fc2e172ab1c33'
));
$request->setHeaders(array(
'content-type' => 'application/json',
'accept' => 'application/json'
));
$request->setBody('{"jobPickupAddress": "Fann Hock, Dakar, Sénégal", "timezone": "0", "jobDeliveryDatetime": "2018-10-24 01:00:00"}');
try {
$response = $request->send();
echo $response->getBody();
} catch (HttpException $ex) {
echo $ex;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment