PHP code example of phpinfo / smsfeedback

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

    

phpinfo / smsfeedback example snippets


$client = ApiClientFactory::createApiClient('login', 'password');

$client->send('71234567', 'Some SMS Text');

$client = ApiClientFactory::createApiClient('login', 'password', 'https://service.mock', 3000);

use Monolog\Handler\StreamHandler;
use Monolog\Logger;

$handler = new StreamHandler(STDOUT);
$logger  = new Logger('SmsFeedback', [$handler]);
        
$client = ApiClientFactory::createApiClient('login', 'password', null, null, $logger);
$client->balance();

$message = $client->send('79161234567', 'SMS Text');

$statuses = $client->status(['5169837636', '5169837647']);

$balances = $client->balance();

$senders = $client->senders();

$client = ApiClientBuilder::create('login', 'password')
    ->setHttpClientParams(
        [
            'base_uri' => 'https://my-domain.com',
            'timeout'  => 5.2,
        ]
    )
    ->getApiClient();

$stack = HandlerStack::create();

$stack->push(function (callable $handler) use ($login, $password) {
    return new AuthorizationMiddleware($handler, $login, $password);
});

$client = ApiClientBuilder::create()
    ->setHttpClientParams(
        [
            'base_uri' => 'http://api.smsfeedback.ru',
            'timeout'  => 5.0,
            'handler'  => $stack,
        ]
    )
    ->getApiClient();

$stack = HandlerStack::create();

$stack->push(function (callable $handler) use ($login, $password) {
    return function (RequestInterface $request, array $options) use ($handler, $login, $password) {
        $fn = $handler;

        $authHeader = sprintf('Basic %s', base64_encode($login . ':' . $password));
        $request = $request->withHeader('Authorization', $authHeader);

        return $fn($request, $options);
    };
});

$client = ApiClientBuilder::create()
    ->setHttpClientParams(
        [
            'base_uri' => 'http://api.smsfeedback.ru',
            'timeout'  => 5.0,
            'handler'  => $stack,
        ]
    )
    ->getApiClient();

$stack = HandlerStack::create();

$logger    = new Logger('SmsFeedback', [$handler]);
$formatter = new MessageFormatter(MessageFormatter::SHORT);

$stack->push(Middleware::log($logger, $formatter));

$client = ApiClientBuilder::create()
    ->setHttpClientParams(
        [
            'base_uri' => 'http://api.smsfeedback.ru',
            'timeout'  => 5.0,
            'handler'  => $stack,
        ]
    )
    ->getApiClient();