예제 #1
0
<?php

/**
 * Example presents usage of the successful getSubmission() API method
*/
use SphereEngine\Api\CompilersClientV3;
// require library
require_once '../../../autoload.php';
// define access parameters
$accessToken = '<access_token>';
$endpoint = '<endpoint>';
// initialization
$client = new CompilersClientV3($accessToken, $endpoint);
// API usage
$response = $client->getSubmission(2016);
<?php

/**
 * Example presents error handling for getSubmission() API method
*/
use SphereEngine\Api\CompilersClientV3;
use SphereEngine\Api\SphereEngineResponseException;
// require library
require_once '../../../autoload.php';
// define access parameters
$accessToken = '<access_token>';
$endpoint = '<endpoint>';
// initialization
$client = new CompilersClientV3($accessToken, $endpoint);
// API usage
try {
    $nonexisting_submission_id = 999999999;
    $response = $client->getSubmission($nonexisting_submission_id);
} catch (SphereEngineResponseException $e) {
    if ($e->getCode() == 401) {
        echo 'Invalid access token';
    } elseif ($e->getCode() == 404) {
        echo 'Submission does not exist';
    }
}