PHP code example of info-com / econtext-sdk-php

1. Go to this page and download the library: Download info-com/econtext-sdk-php 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/ */

    

info-com / econtext-sdk-php example snippets


$url = new eContext\Classify\Type\Url($client);
$urls = ['http://www.cnn.com', 'http://www.econtext.ai', 'http://www.nytimes.com'];
$url->setData($urls);
$results = $url->classify(3); # classify all pages at once

$i = 0;
foreach($results->yieldResults() as $url_result) {
    echo $urls[$i++] . PHP_EOL;
    echo $url_result['title'] . PHP_EOL;
    echo "Categories:" . PHP_EOL;
    foreach($url_result['scored_categories'] as $scored_category) {
        echo "  " . $results->getCategory($scored_category['category_id'])['name'] . " : " . $scored_category['score'] . PHP_EOL
    }
}