1. Go to this page and download the library: Download coopcycle/coopcycle-php-sdk library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
coopcycle / coopcycle-php-sdk example snippets
use CoopCycle\Client;
$client = new Client([
'base_uri' => 'https://acme.coopcycle.org',
'client_id' => 'YourClientId',
'client_secret' => 'YourClientSecret'
]);
$request = [
'pickup' => [
'address' => '50, Rue de Rivoli, Paris'
],
'dropoff' => [
'address' => '90, Rue de Rivoli, Paris',
'before' => 'today 13:00'
],
];
$response = $client->deliveries->create($request);
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class WebhookHandler {
public function __invoke(Request $request)
{
$payload = $request->getContent();
$signature = $request->headers->get('X-CoopCycle-Signature');
// You will probably restore the secret from your database instead
$secret = "4mCOyJ7UAa371oUjYcC2R9BZRx5eQT08qTzLAnh4e8M=";
if (!$client->webhooks->verifySignature($payload, $signature, $secret)) {
return new Response('Invalid webhook signature', 400);
}
return new Response('OK', 200);
}
}
php composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.