基于SSL进行noti失败的问题
谢谢关注,我的是php环境,通过curl发起ssl请求,但是返回如下:Array( => {"cmd":"invalid_msg","msg":"Request data is not a valid JSON or there are other errors."} => 0)请求脚本为:
function ssl()
{
$header=array(
'Content-Type:application/json'
);
// $params=array(
// "cmd"=> "enterprise_login_req",
// "data"=> array(
// "enterprise_id"=>"9b05faaf62e74b7da507d2b85e9fd21b",
// "enterprise_secret"=>"a4c372737c934cf88d60f83dbb5c98e3",
// "prefetch_count"=>5)
// );
$params=array(
"cmd"=> "enterprise_login_req",
"data"=> array(
"enterprise_id"=>"9b05faaf62e74b7da507d2b85e9fd21b",
"enterprise_secret"=>"a4c372737c934cf88d60f83dbb5c98e3",
"prefetch_count"=>5)
);
$data="{\"cmd\": \"enterprise_login_req\",\"data\": {\"enterprise_id\": \"9b05faaf62e74b7da507d2b85e9fd21b\",\"enterprise_secret\": \"a4c372737c934cf88d60f83dbb5c98e3\",\"prefetch_count\": 50}}\n";
$params_query=json_encode($params)."\n";
$result=curl_post_https("https://noti.gizwitsapi.com:2015",$data,30,$header);
echo '<pre>';
print_r($result);
return $result;
}
function curl_post_https($url,$data='',$timeout=30,$header=array()){
$arrCurlResult = array();
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);//ssl检测跳过
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
curl_setopt ( $ch,CURLOPT_REFERER,"");
$output = curl_exec($ch);
$responseCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
$arrCurlResult['output'] = $output;//返回结果
$arrCurlResult['code'] = $responseCode;//返回http状态
curl_close($ch);
unset($ch);
return $arrCurlResult;
}请问我哪里写错了吗,该如何调整?
谢谢~~~
祝一切安好~~
页:
[1]