1. Go to this page and download the library: Download suq/suq-k2-connect-php 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/ */
suq / suq-k2-connect-php example snippets
//Store your client id and client secret as environment variables
//Including the kopokopo sdk
use Kopokopo\SDK\K2;
// do not hard code these values
$options = [
'clientId' => 'YOUR_CLIENT_ID',
'clientSecret' => 'YOUR_CLIENT_SECRET',
'apiKey' => 'YOUR_API_KEY',
'baseUrl' => 'https://sandbox.kopokopo.com'
];
$K2 = new K2($options);
use Kopokopo\SDK\K2;
// Do not hard code these values
$options = [
'clientId' => 'YOUR_CLIENT_ID',
'clientSecret' => 'YOUR_CLIENT_SECRET',
'apiKey' => 'YOUR_API_KEY',
'baseUrl' => 'https://sandbox.kopokopo.com'
];
$K2 = new K2($options);
// Get one of the services
$tokens = $K2->TokenService();
// Use the service
$result = $tokens->getToken();
//print the result
print_r($result);
// TODO: review this
$router->map('POST', '/webhook', function () {
global $K2;
global $response;
$webhooks = $K2->Webhooks();
$json_str = file_get_contents('php://input');
var_dump($json_str);
$response = $webhooks->webhookHandler($json_str, $_SERVER['HTTP_X_KOPOKOPO_SIGNATURE']);
echo json_encode($response);
});