Library
public function doRequest($url, $para)
{
do {
if(extension_loaded('curl')) {
$ch = curl_init();
$options = array(
CURLOPT_URL => $url,
CURLOPT_HEADER => 0,
CURLOPT_POST => 1,
CURLOPT_POSTFIELDS => $para,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SSLVERSION => 1,
CURLOPT_CONNECTTIMEOUT => 5,
CURLOPT_USERAGENT => $_SERVER['HTTP_USER_AGENT'],
);
curl_setopt_array($ch, $options);
$data = curl_exec($ch);
$info = curl_getinfo($ch);
$error = curl_error($ch);
curl_close($ch);
if(get_magic_quotes_gpc()) {
$data = stripslashes($data);
}
$decode = json_decode($data, true);
if(json_last_error() === JSON_ERROR_NONE) {
$err = array(
'status' => 'success',
'results' => $info,
);
}
else
{
$err = array(
'status' => 'failed',
'results' => '返回值非JSON 类型',
);
}
} else {
$err = array(
'status' => 'failed',
'results' => '请开启PHP Curl 拓展',
);
}
return $err;
} while(0);
}
Controller
public function how_old()
{
$url = config_item('how_old_url');
$data = array(
'isTest' => false,
'faceName' => 'Test',
'faceUrl' => 'http://www.sinaimg.cn/dy/slidenews/4_img/2015_12/704_1579346_230297.jpg',
);
$this->load->library('cuiqg');
var_dump( $this->cuiqg->doRequest($url, $data))];
}
Browser
奇怪 没有任何 打印 他是怎么显示出来的 ,在一个
gettype()
doRequest()
$data 是bool 类型的 怎么处理, 还有就是这些转义字符怎么去掉 ~_~||
小伙看你根骨奇佳,潜力无限,来学PHP伐。