我正在设置返回JSON的服务器,但是,执行curl后会出现错误
我可以在chrome和postmen中得到响应,但在离子上却失败
<?php
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
$ch = curl_init();
$message='vendor=mobi&username=x&sid='.session_id().'';
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_URL,'http://xxx);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$message);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_COOKIE, $strCookie );
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 0);
curl_setopt($ch, CURLOPT_TIMEOUT, 800);
$server_output = curl_exec($ch);
curl_close ($ch);
$data=array();
$data=array('a'=>'b');
echo json_encode($data);
?>
我希望输出'a'=>'b',但是ionic使用数据订阅将其获取HttpErrorResponse
答案 0 :(得分:0)
应删除
$strCookie = 'PHPSESSID=' . $_COOKIE['PHPSESSID'] . '; path=/';
curl_setopt($ch, CURLOPT_COOKIE, $strCookie );
并将其更改为
curl_setopt ($ch, CURLOPT_COOKIEFILE, '');