Example

Example

<?php

# Description: Comparator API usage example.
# Copyright: (C) 2016 EffectiveSoft Ltd. All Rights Reserved.
# Technical support: technical-support@effective-soft.com

header('Content-Type: text/plain');

# ----------- cURL -----------
# set the URL for GET request, specify comparison urls and API key for authorization purposes (change YourAPIKey to the Intellexer API key)
$link = "http://api.intellexer.com/compareUrls?apikey=YourAPIKey&url1=http://www.infoplease.com/biography/var/barackobama.html&url2=http://millercenter.org/president/biography/obama-life-in-brief&useCache=false";

# curl connection initialization
$ch = curl_init();

#set cURL options
curl_setopt_array($ch, array(
    CURLOPT_URL => $link,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_POST => false,
    CURLOPT_HEADER => false,
    CURLOPT_FOLLOWLOCATION => true
));

# perform the request
$results = curl_exec($ch);

# error checking
if (curl_errno($ch))
{
    echo 'CURL error: ' . curl_error($ch);
}
else {
    # parse JSON results
    $json_results = json_decode($results, true);
}

# print "Proximity between"
echo 'Proxomity between: ' . "\n";
echo $json_results['document1']['title'] . " and " . $json_results['document2']['title'] . " is " . $json_results['proximity'];

curl_close($ch);
# ----------- END cURL -----------

Output

Proxomity between: 
barackobama.html.html and obama-life-in-brief.html is 0.626789503046