Showing posts with label Summarity. Show all posts
Showing posts with label Summarity. Show all posts

Friday 19 November 2010

PHP API call to Summarity

Summarity at http://www.summarity.com/ is software which summarises items of text. They helpfully provide an API for developers to use. There is an example of how to call the API using python on the website. I don't use python. I use PHP. So I went about writing the API call in PHP. So below is an example of how it's done. You will need to get your own API key. I hope it's obvious where to add your text string.

<?php

 $url = 'http://summarity.com/apiV1';
 $data = 'summarity_api_key=yourAPIkey';
 $data .= '&text='.urlencode('Just some text for testing');
                 
 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_POST, 1);
 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                
 $response = curl_exec($ch);                
 curl_close($ch);
 echo(json_decode($response));
?>