PHP code example of trexima / sri-client

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

    

trexima / sri-client example snippets




use GuzzleHttp\Exception\GuzzleException;
use Symfony\Component\Cache\Adapter\ArrayAdapter;
use Trexima\SriClient\Exception\GraphQLException;
use Trexima\SriClient\v2\Client;

ameterExtractor, $cache);

// make request
try {
    $activity = $sriClient->getActivityDetail('1');
} catch (GuzzleException $e) {
    // TODO handle exception
}

var_dump($activity);

// make GraphQL request
try {
    $query = sprintf('
        {
            activitiesTimeline (id: \"/api/activities_timeline/%s\") {
                id,
                name,
                content,
                dateFrom,
                dateTo
            }
        }', 1);
    $graphQLquery = '{"query": "query ' . str_replace(array("\n", "\r"), '', $query) . '"}';
    $activity = $sriClient->getGraphQL($graphQLquery);
} catch (GraphQLException $e) {
    $errors = $e->getGraphQLErrors();
    $data = $e->getData();
    $message = $e->getMessage();
    // TODO handle GraphQL error
} catch (GuzzleException $e) {
    $message = $e->getMessage();
    $httpCode = $e->getCode();
    if ($e->hasResponse()) {
        $response = $e->getResponse();
    }
    // TODO handle Guzzle error
}

var_dump($activity);

docker-php-ext-install pdo_mysql
docker-php-ext-enable pdo_mysql
/etc/init.d/apache2 reload