Localhost Üzerinde Çalışan cURL İşleminin Sunucuda Çalışmaması
Merhaba arkadaşlar, cURL ile web sitesinden veri çekmeye çalışıyorum, localhost üzerinden sorunsuz çekiyor ama sunucuda çekmek istediğimde boş değer dönüyor.
Kullanıdğım fonksiyon budur;
function curlKullan($url){
$curl = curl_init();
curl_setopt($curl,CURLOPT_REFERER,'http://google.com');
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,true); // return web page
curl_setopt($curl, CURLOPT_HEADER,true); //return headers in addition to content
curl_setopt($curl, CURLOPT_FOLLOWLOCATION,true); // follow redirects
curl_setopt($curl, CURLOPT_ENCODING,"utf-8"); // handle all encodings
curl_setopt($curl, CURLOPT_AUTOREFERER,true); // set referer on redirect
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT,120); // timeout on connect
curl_setopt($curl, CURLOPT_MAXREDIRS,10); // stop after 10 redirects
curl_setopt($curl, CURLINFO_HEADER_OUT,true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,false); // Disabled SSL Cert checks
curl_setopt($curl, CURLOPT_POST,0);
curl_setopt($curl,CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
$cikti = curl_exec($curl);
curl_close($curl);
$cikti = str_replace(array("n","t","r"), null, $cikti);
return $cikti;
}
$url = curlKullan('https://www.cctvcalculator.net/api/calculation.php?jsoncallback=jQuery214038336959030315054_1585735346782&calc=storage&security=a9f5523fe5&motion=1.00&resolution=640-360&codec=340&cameras=1&mfps=1&nfps=10&days=1');
print_r($url);
//Localhostta
//HTTP/2 200 server: nginxdate: Thu, 02 Apr 2020 07:10:00 GMTcontent-type: application/x-javascriptexpires: Thu, 19 Nov 1981 08:52:00 GMTcache-control: no-store, no-cache, must-revalidatepragma: no-cacheset-cookie: PHPSESSID=k69ofnpfvjchntlpggm4hinh8v; path=/jQuery214038336959030315054_1585735346782({"storage":22.1})
//Sunucuda
//HTTP/2 200 server: nginxdate: Thu, 02 Apr 2020 07:11:12 GMTcontent-type: text/htmlcontent-length: 0expires: Thu, 19 Nov 1981 08:52:00 GMTcache-control: no-store, no-cache, must-revalidatepragma: no-cacheset-cookie: PHPSESSID=egtkg2l7vd790fo5c59crqm79a; path=/
Soru hatalı mı? 👎
Eğer sorunun kurallara aykırı olduğunu düşünüyorsanız lütfen bize bildirin!
Cevaplar (2)
cURL support enabled
cURL Information 7.62.0
Age 4
Features
AsynchDNS Yes
CharConv No
Debug No
GSS-Negotiate No
IDN No
IPv6 Yes
krb4 No
Largefile Yes
libz Yes
NTLM Yes
NTLMWB Yes
SPNEGO Yes
SSL Yes
SSPI No
TLS-SRP No
Protocols dict, file, ftp, ftps, gopher, http, https, imap, imaps, ldap, ldaps, pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Host x86_64-redhat-linux-gnu
SSL Version OpenSSL/1.0.2k
ZLib Version 1.2.7
libSSH Version libssh2/1.8.0