PHP code example of wildix / s2s-client-php

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

    

wildix / s2s-client-php example snippets


$config = [
    'host' => 'https://example-host.com',
    'app_id' => 'APP_ID',
    'secret_key' => 'APP_SECRET',
    'app_name' => 'APP_NAME',
];

$client = new \Wildix\Integrations\Client($config, []);

$config = [
    'host' => 'https://example-host.com',
    'app_id' => 'APP_ID',
    'secret_key' => 'APP_SECRET',
    'app_name' => 'APP_NAME',
];

//example params
$params = [
    // You can set any number of default request options.
    'timeout'  => 2.0
];

$client = new \Wildix\Integration\Client($config, $params);

$options = [
    'params' => [
        'param1'=>'value1',
        'param2'=>'value2',
    ]
];
$response = $client->get('/api/v1/example/', $options);

echo $response->getStatusCode(); // 200
echo $response->getHeaderLine('content-type'); // 'application/json; charset=utf8'
echo $response->getBody()->getContents(); // '{"type": "result", "result": {}}'


For convenience aliases have been provided for supported request methods.

$options = [
    'params' => [
        'param1'=>'value1',
        'param2'=>'value2',
    ],
    'body' => [
        'field1'=>'value1',
        'field2'=>'value2',
    ],
    'headers' => [
        'content-type' => 'application/json'
    ]
];

$client->post(apiPoint[, $options]);


$options = [
    // 'params' are the URL parameters to be sent with the request
    'params' => [
        'param1'=>'value1',
        'param2'=>'value2',
    ],
    // 'body' is the data to be sent as the request body
    'body' => [
        'field1'=>'value1',
        'field2'=>'value2',
    ],
    // 'headers' are custom headers to be sent
    'headers' => [
        'content-type' => 'application/json'
    ]
];

bash
$ composer