PHP code example of textrazor / textrazor-php

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

    

textrazor / textrazor-php example snippets


    
    RazorSettings::setApiKey('YOUR_API_KEY_HERE');
    
    $text = 'Barclays misled shareholders and the public about one of the biggest investments in the banks history, a BBC Panorama investigation has found.';
    
    $textrazor = new TextRazor();
    
    $textrazor->addExtractor('entities');
    
    $response = $textrazor->analyze($text);
    if (isset($response['response']['entities'])) {
        foreach ($response['response']['entities'] as $entity) {
            print_r($entity['entityId'] . PHP_EOL);
        }
    }

composer