Example

Example

<?php

# Description: Summarizer 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 url, summarization parameters and API key for authorization purposes (change YourAPIKey to the Intellexer API key)
$link = "http://api.intellexer.com/summarize?apikey=YourAPIKey&url=http://www.infoplease.com/biography/var/barackobama.html&summaryRestriction=7&returnedTopicsCount=2";

# 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 "Document structure"
echo 'Document structure: ' . $json_results['structure'];

# print "Document topics"
echo "\n" . 'Document topics: ';
$topics = $json_results['topics'];
foreach ($topics as $topic) {
    echo $topic;
}

# print "Document summary"
echo "\n" . 'Document summary: ' . "\n";
$items = $json_results['items'];
foreach ($items as $item) {
    echo $item['text'] . "\n";
}

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

Output

Document structure: NewsArticle
Document topics: Social.politics
Document summary: 
Best known as:  President of the United States, 2009-present
Barack Obama is the 44th president of the United States and the first African-American president in American history.
Barack Obama was elected to the Illinois Senate in 1996, and then to the U.S. Senate in 2004, beating Republican candidate Alan Keyes .
Obama ran for president in 2008, defeating a Democratic primary field that included New York Sen. Hillary Clinton , the former First Lady.
Barack Obama published the personal memoir Dreams from My Father  in 1995, and published a second book, The Audacity of Hope , in 2006.
Two other African-Americans were chosen by state senates to become U.S. Senators: Hiram Revels (1870-71, from Mississippi) and Blanche Bruce  (1875-81, also from
Mississippi)… His 2008 Grammy for The Audacity of Hope  beat books by two former presidents: Bill Clinton 's Giving: How Each of Us Can Change the World  and Jimmy Carter 's Sunday Mornings in Plains: Bringing Peace to a Changing World .