You need to convert the $data array to a string ... Also, make sure urlencode() separate value.
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://nlp.stanford.edu:8080/corenlp/process"); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_USERAGENT,"Mozilla/14.0 (compatible; MSIE 6.0; Windows NT 5.1)"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_POST, true); $data = array( "outputFormat" => "xml", "input" => "Here is a statement to process", "Process" => "Submit Query" ); $data_string = ""; foreach($data as $key=>$value){ /// YOU HAVE TO DO THIS $data_string .= $key.'='.urlencode($value).'&'; /// AND THIS } curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); $result = curl_exec($ch); echo $result;
source share