Extract sentiment statistics from text

Notes

  • The API key and format parameters can be passed in the query string, while the other parameters should be posted as JSON in the message body (see example below).
$obj = array(
	"text" => "I love natural language processing!  NLP is lots of fun.",
	"entities" => array(array("nlp", "natural language processing"))
);

$options = array(
  'http' => array(
    'method'  => 'POST',
    'content' => json_encode($obj),
    'header'=>  "Content-Type: application/json\r\n" .
                "Accept: application/json\r\n"
    )
);

$context  = stream_context_create($options);
$result = file_get_contents("http://api.addstructure.com/v1/analysis/sentimentstats?key=APIKEY", false, $context);
echo($result);
Language