PHP code example of ocolin / tarana-tsp

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

    

ocolin / tarana-tsp example snippets


// Manual creation for demonstration
$_ENV['TARANA_TSP_API_HOST'] = 'https://api.tsp.taranawireless.com/';
$_ENV['TARANA_TSP_API_TOKEN'] = 'abcdefg';
$tarana = new Ocolin\TaranaTSP\TaranaTSP();

$tarana = new Ocolin\TaranaTSP\TaranaTSP(
     host: 'https://api.tsp.taranawireless.com/',
    token: 'abcdefg'
);

// Manual creation for demonstration
$_ENV['TARANA_TSP_API_HOST'] = 'https://api.tsp.taranawireless.com/';
$_ENV['TARANA_TSP_API_TOKEN'] = 'abcdefg';
$tarana = new Ocolin\TaranaTSP\TaranaTSP(
    options: [ 'verify' => false, 'timeout' => 20 ]
);

$output = $tarana->request(
    endpoint: '/v0/predict/multi-sector/status/{request_id}',
      method: 'GET',
       query: [ 'request_id' => 1234 ]
);

$output = $tarana->requestForm(
    endpoint: '/v0/find/bns/issue',
      method: 'POST',
       query: [ 'response_format' => 'csv' ],
        body: [ 'operator' => 'abcdefg' ]
);

$output = $tarana->requestMultipart(
     endpoint: '/v0/predict/multi-sector/csv',
       method: 'POST',
    filePaths: [ 'height_csv_file.csv' => 'bn_csv_file.csv' ],
         body: [ 'operator' => 'abcdefg' ],
        query: [ 'bn_limit' => 5 ]
);

$output = $tarana->checkApiKey();

$output = $tarana->findBnsWithIssues(
    format: 'csv',      // Output format json or csv
    operator: 'abcdefg' // Operator ID 
);

$output = $tarana->predictReport( download: true );

$output = $tarana->predictMultiSector(
    body: {...},
    bnLimit: 10
);

$output = $tarana->submitMultiSector(
    body: {...},
    bnLimit: 10
);

$output = $tarana->getStatus( requestId: 'abcdefg' );

$output = $tarana->getResult( requestId: 'abcdefg' );

$output = $tarana->predictMultiSectorCsv( rnCsvFilePath: 'file.csv' );

$output = $tarana->submitMultiSectorCsv( rnCsvFilePath: 'file.csv' );

// 1. Submit
$job = $tarana->submitMultiSector( body: $data );
$requestId = $job->body['request_id'];

// 2. Poll until complete
do {
    sleep( 5 );
    $status = $tarana->getStatus( requestId: $requestId );
} while( $status->body['prediction_state'] !== 'completed' );

// 3. Fetch results
$result = $tarana->getResult( requestId: $requestId );