-
-
Save vpekar/0b527032a43ab9d73ff0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ch = curl_init(); | |
$headers = array("Content-Type: application/x-www-form-urlencoded; charset=UTF-8", | |
"<ACCESS-KEY-HEADER>: <ACCESS-KEY>"); | |
curl_setopt($ch, CURLOPT_URL, "<ACCESS-URL>"); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); | |
curl_setopt($ch, CURLOPT_HEADER, FALSE); | |
curl_setopt($ch, CURLOPT_POST, TRUE); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); | |
$fields = array('text'=>"The food was great, but the service was slow.", 'lang'=>'en', | |
'keywords' =>1, 'sentiment'=>1, 'annotate'=>1); | |
$postvars = ''; | |
foreach($fields as $key=>$value) { | |
$postvars .= $key . "=" . $value . "&"; | |
} | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvars); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); | |
$response = curl_exec($ch); | |
echo $response; | |
curl_close($ch); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment