<?php

include "libs/hodclient.php";
include "libs/hodresponseparser.php";
$hodClient = new HODClient("API_KEY");
$paramArr = array('url' => ["http://www.bbc.com", "http://www.cnn.com"], "entity_type" => ["people_eng", "places_eng", "companies_eng"], "unique_entities" => "true");
try {
    $response = $hodClient->GetRequest($paramArr, HODApps::ENTITY_EXTRACTION, false);
    $resp = new HODResponseParser($response);
    if ($resp->error != null) {
        echo "Error code: " . $resp->error->error . "</br>Error reason: " . $resp->error->reason . "</br>Error detail: " . $resp->error->detail;
    } elseif ($resp->status == "finished") {
        $people = "";
        $places = "";
        $companies = "";
        $entities = $resp->payloadObj->entities;
        for ($i = 0; $i < count($entities); $i++) {
            $entity = $entities[$i];
            if ($entity->type == "people_eng") {
                $people .= $entity->normalized_text . "</br>";
                // parse any other interested information about this person ...
            } else {
                if ($entity->type == "places_eng") {
                    $places .= $entity->normalized_text . "</br>";
                    // parse any other interested information about this place ...
                } else {
                    if ($entity->type == "companies_eng") {
                        $companies .= $entity->normalized_text . "</br>";
                        // parse any other interested information about this place ...
                    }
                }
<?php

include "libs/hodclient.php";
include "libs/hodresponseparser.php";
$hodClient = new HODClient("API_KEY");
// implement callback function
function requestCompletedWithJobId($response)
{
    global $hodClient;
    $resp = new HODJobIDParser($response);
    if ($resp->error != null) {
        echo json_encode($resp->error);
    } else {
        try {
            $hodClient->GetJobStatus($resp->jobID, 'requestCompletedWithContent');
        } catch (Exception $ex) {
            echo $ex . getMessage();
        }
    }
}
// implement callback function
function requestCompletedWithContent($response)
{
    global $hodClient;
    $resp = new HODResponseParser($response);
    if ($resp->error != null) {
        $err = $resp->error;
        if ($err->error == HODErrorCode::QUEUED) {
            error_log("queued:" . $err->jobID);
            sleep(2);
            try {
<?php

include "libs/hodclient.php";
include "libs/hodresponseparser.php";
$hodClient = new HODClient("API_KEY");
$paramArr = array('file' => "0005r005.gif", 'mode' => "document_photo");
try {
    $response = $hodClient->PostRequest($paramArr, HODApps::OCR_DOCUMENT, true);
    $resp = new HODJobIDParser($response);
    if ($resp->error != null) {
        echo json_encode($resp->error);
    } else {
        $response = $hodClient->GetJobResult($resp->jobID);
        $resp = new HODResponseParser($response);
        if ($resp->error != null) {
            $error = "<b>Error:</b></br>";
            $error .= $resp->error->error . "</br>";
            $error .= $resp->error->reason . "</br>";
            $error .= $resp->error->detail . "</br>";
            echo $error;
        } elseif ($resp->status == "finished") {
            $result = "";
            $textBlocks = $resp->payloadObj->text_block;
            for ($i = 0; $i < count($textBlocks); $i++) {
                $block = $textBlocks[$i];
                $result .= "<html><body><p>";
                $result .= preg_replace("/\n+/", "</br>", $block->text);
                $result .= "</p></body></html>";
            }
            echo "RECOGNIZED TEXT: " . $result;
        }
<?php

include "libs/hodclient.php";
include "libs/hodresponseparser.php";
$hodClient = new HODClient("API_KEY");
// implement callback function
function requestCompletedWithContent($response)
{
    $resp = new HODResponseParser($response);
    if ($resp->error != null) {
        echo "Error code: " . $resp->error->error . "</br>Error reason: " . $resp->error->reason . "</br>Error detail: " . $resp->error->detail;
    } elseif ($resp->status == "finished") {
        $people = "";
        $places = "";
        $companies = "";
        $entities = $resp->payloadObj->entities;
        for ($i = 0; $i < count($entities); $i++) {
            $entity = $entities[$i];
            if ($entity->type == "people_eng") {
                $people .= $entity->normalized_text . "</br>";
                // parse any other interested information about this person ...
            } else {
                if ($entity->type == "places_eng") {
                    $places .= $entity->normalized_text . "</br>";
                    // parse any other interested information about this place ...
                } else {
                    if ($entity->type == "companies_eng") {
                        $companies .= $entity->normalized_text . "</br>";
                        // parse any other interested information about this place ...
                    }
                }