PHP code example of craymend / stannp-php-sdk

1. Go to this page and download the library: Download craymend/stannp-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/ */

    

craymend / stannp-php-sdk example snippets



Craymend\Stannp\Request;

echo "Query test endpoint\n";

$apiKey = 'your-api-key';
$request = new Request($apiKey);

$response = $request->testEndpoint();

if($response->success){
    echo "Endpoint Test SUCCESS: $response->statusCode\n";
    echo 'User id: ' . json_encode($response->data->data->id) . "\n";
}else{
    echo "Endpoint Test FAIL: $response->statusCode\n";
    echo 'Errors: ' . json_encode($response->error) . "\n";
}


Craymend\Stannp\Request;

$apiKey = 'your-api-key';
$request = new Request($apiKey);

// Test getting recipient
echo 'Test getting recipient: ' . $uri . "\n";

$recipientId = '111111111111';
$uri = '/v1/recipients/get/' . $recipientId;
$response = $request->get($uri, []);

if($response->success){
    echo 'Data: ' . json_encode($response->data) . "\n";
}else{
    echo "Error $response->statusCode: " . json_encode($response->error) . "\n";
}

// Test querying an error
echo "Test error query\n";

$uri = '/v1/not-an-endpoint';
$response = $request->get($uri, []);

if($response->success){
    echo 'Data: ' . json_encode($response->data) . "\n";
}else{
    echo "Error $response->statusCode: " . json_encode($response->error) . "\n";
}

composer