wildix / s2s-client-php
php sdk wildix
Installs: 4 373
Dependents: 1
Suggesters: 0
Security: 0
Stars: 6
Watchers: 3
Forks: 6
Open Issues: 1
Requires
- php: >=8.0
- ext-curl: *
- ext-json: *
- firebase/php-jwt: ^v6.9.0
- guzzlehttp/guzzle: ^6.5.8
Requires (Dev)
- mockery/mockery: ^1.6.6
- php-mock/php-mock-phpunit: ^2.7
- phpunit/phpunit: ^8.5.34
- squizlabs/php_codesniffer: 3.*
- symfony/var-dumper: ^v6.3.5
This package is auto-updated.
Last update: 2024-05-23 09:48:39 UTC
README
Wildix Integration is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services.
$ composer require wildix/s2s-client-php
Example
Create instance
$config = [ 'host' => 'https://example-host.com', 'app_id' => 'APP_ID', 'secret_key' => 'APP_SECRET', 'app_name' => 'APP_NAME', ]; $client = new \Wildix\Integrations\Client($config, []);
Create custom instance defaults
Params using all params from guzzle http client.
$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);
Example 'GET' query
$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": {}}'
Request method aliases
$client->get(apiPoint[, $options])
$client->delete(apiPoint[, $options])
$client->post(apiPoint[, $options])
$client->put(apiPoint[, $options])
Examples
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]);
Request options config
$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' ] ];