我正在尝试从多个URL获取数据,但是当我将动态URL提供给CURL lib时,它将返回我#null。如果给出硬单码URL,则返回数据。
public function index()
{
$id="1234567899555";
$data=$this->db->select('*')->from('URL')->where('is_delete',0)->get()->result();
foreach($data as $values){
$URL=$values->URL.$id;
//var_dump($URL); die();
$cSession = curl_init();
//step2
curl_setopt($cSession,CURLOPT_URL, $URL);
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true);
curl_setopt($cSession,CURLOPT_HEADER, false);
//var_dump(CURLOPT_URL); die();
//step3
$result=curl_exec($cSession);
//step4
curl_close($cSession);
//step5
//var_dump($result); die();
$slm=json_decode($result);
var_dump($slm); die();
}
}