我想打电话给Api。我已经使用了Curl并创建了一个库。当我从控制器调用Curl库函数时,它返回NULL但是如果我打印响应它会显示数据。谁能帮我?
My Curl Library code :
public function callApi($jwt_tkn, $url, $postdata, $method)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer ' . $jwt_tkn));
curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}