PHP code example of sendynl / php-sdk

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

    

sendynl / php-sdk example snippets




$connection = new \Sendy\Api\Connection();

$connection->setAccessToken('your-personal-access-token');

$connection->me->get();

$connection = new \Sendy\Api\Connection();

$connection->setOauthClient(true);

$connection->setClientId('your-client-id')
    ->setClientSecret('your-client-secret')
    ->setRedirectUrl('your-callback-url');

$connection->redirectForAuthorization();

$connection = new \Sendy\Api\Connection();

$connection->setClientId('your-client-id')
    ->setClientSecret('your-client-secret')
    ->setRedirectUrl('your-callback-url');

// Either an authorization code or a refresh token is nnection->setTokenExpires(1123581321);

$connection->me->get();

// Store the access token, refresh token en the expiration timestamp in your application to prevent unnecessary
// requesting new access tokens
$connection->getAccessToken();
$connection->getRefreshToken();
$connection->getTokenExpires();

$connection = new \Sendy\Api\Connection();

$connection->setOauthClient(true);

$connection->setClientId('your-client-id')
    ->setClientSecret('your-client-secret')
    ->setRedirectUrl('your-callback-url')
    ->setTokenUpdateCallback(function (\Sendy\Api\Connection $connection) {
        $data = [
            'access_token' => $connection->getAccessToken(),
            'refresh_token' => $connection->getRefreshToken(),
            'token_expires' => $connection->getTokenExpires(),
        ];
        
        // Use this data to store the tokens in your application
    });

composer