<?php $url="http://api.ickd.cn/?id=106658&secret=21af383a867adff271dd76cf2fc9b851&com=yuantong&nu=883200943093094226&type=json&encode=utf8&ord=asc";//請求路徑 function https_request($url, $data = null){ $curl = curl_init();//初始化 curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if (!empty($data)){ curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); curl_close($curl);//關閉curl return $output; } $res=https_request($url); print_r($res); 登陸接口 $url="http://localhost/shop/index.php/Home/Login/login"; $data=array( 'username'=>"wu", 'password'=>"1234" ); $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($curl); print_r($output); curl_close($curl); ?>