PHP code example of sharpapi / php-travel-review-sentiment

1. Go to this page and download the library: Download sharpapi/php-travel-review-sentiment 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/ */

    

sharpapi / php-travel-review-sentiment example snippets




harpAPI\TravelReviewSentiment\TravelReviewSentimentClient;
use GuzzleHttp\Exception\GuzzleException;

$apiKey = 'your_api_key_here';
$client = new TravelReviewSentimentClient(apiKey: $apiKey);

try {
    $statusUrl = $client->analyzeTravelReviewSentiment(
        content: 'Your text content here',
        language: 'English'
    );

    // Optional: Configure polling
    $client->setApiJobStatusPollingInterval(10);
    $client->setApiJobStatusPollingWait(180);

    // Fetch results (polls automatically)
    $result = $client->fetchResults($statusUrl);
    $resultData = $result->getResultJson();

    echo $resultData;
} catch (GuzzleException $e) {
    echo "API error: " . $e->getMessage();
}