Skip to content

Instantly share code, notes, and snippets.

@hackerrahul hackerrahul/sentiment.php
Last active Jul 1, 2019

What would you like to do?
function detect_sentiment($string){
$string = urlencode($string);
$api_key = "YOUR_API_KEY";
$url = ''.$api_key.'&string='.$string.'';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$response = json_decode($result,true);
return $response;
$string = "This Sentiment analysis api is very good!";
$data = detect_sentiment($string);
echo "<pre>";
echo "</pre>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.