Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?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