need help with php curl
I have two files. one the sends out the curl post and another that receive the post, runs a query.
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL,"http://url/filename.php");
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($curl, CURLOPT_PO开发者_高级运维ST, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($curl, CURLOPT_POSTFIELDS, "col1=data&col2=moredata");
$curlResult = curl_exec ($curl);
curl_close ($curl);
print_r($curlResult );
if($curlResult == "granted"){
echo 'right';
}else{
echo 'wrong';
}
the problem is even though the print_r shows 'granted' the if statement still fails. What am i missing? any help would be awesome.
CURLOPT_RETURNTRANSFER causes curl_exec() to return either false or a string. So the question of whether or not it is an array is that it can't be, because it is a string. Therefore, you most likely have newline or whitespace on there somewhere and need to trim() it.
精彩评论