Új hozzászólás Aktív témák
-
Sk8erPeter
nagyúr
válasz
Lacces #10560 üzenetére
Azért nem működik, mert be kell tenned még ezt:
// This will make cURL follow the redirects (@see http://stackoverflow.com/questions/6028050/curl-returntransfer-is-empty-curl-getinfo-error-1)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);Tehát a teljes függvény:
/**
* Download a website or any other file using cURL
*
* @see http://www.jonasjohn.de/snippets/php/curl-example.htm
* @see http://stackoverflow.com/questions/6028050/curl-returntransfer-is-empty-curl-getinfo-error-1
*
* @param string $Url
* @return string
*/
function curl_download($Url){
// is cURL installed yet?
if (!function_exists('curl_init')){
die('Sorry cURL is not installed!');
}
// OK cool - then let's create a new cURL resource handle
$ch = curl_init();
// Now set some options (most are optional)
// Set URL to download
curl_setopt($ch, CURLOPT_URL, $Url);
// This will make cURL follow the redirects (@see http://stackoverflow.com/questions/6028050/curl-returntransfer-is-empty-curl-getinfo-error-1)
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// Set a referer
curl_setopt($ch, CURLOPT_REFERER, "http://www.example.org/yay.htm");
// User agent
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
// Include header in result? (0 = yes, 1 = no)
curl_setopt($ch, CURLOPT_HEADER, 0);
// Should cURL return or print out the data? (true = return, false = print)
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Timeout in seconds
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
// Download the given URL, and return output
$output = curl_exec($ch);
// Close the cURL resource, and free system resources
curl_close($ch);
return $output;
}Teszt:
$curl_download = curl_download('http://www.example.org/');
echo $curl_download;
Új hozzászólás Aktív témák
- Parfüm topik
- sziku69: Fűzzük össze a szavakat :)
- SQL kérdések
- Milyen nyomtatót vegyek?
- Honor Magic V5 - méret a kamera mögött
- WoW avagy World of Warcraft -=MMORPG=-
- Milyen légkondit a lakásba?
- Vizsgálat indult, a Meta chatbot gyerekekkel folytatott romantikus beszélgetést
- TCL LCD és LED TV-k
- Autós topik
- További aktív témák...
- PlayStation Portal 2026.12.03-ig gyári garanciával eladó!
- ASRock B560 Steel Legend + i5 11500 + ID-Cooling + 16 Gb Corsair Vengeance RGB Beszámitok!
- Samsung Galaxy A26 5G 128GB, Kártyafüggetlen, 1 Év Garanciával
- Apple iPhone 14 128GB, Kártyafüggetlen, 1 Év Garanciával
- Apple iPhone 12 128GB, Kártyafüggetlen, 1 Év Garanciával
- Honor 200 256GB, Kártyafüggetlen, 1 Év Garanciával
- LG 55G3 - 55" OLED evo - 4K 120Hz 0.1ms - MLA - 2000 Nits - NVIDIA G-Sync - AMD FreeSync - HDMI 2.1
- Bomba ár! Dell Latitude E5570 Touch - i5-6300U I 8GB I 256SSD I 15,6" FHD I HDMI I CAM I W10 I Gari
- Xiaomi Redmi Note 13 Pro 5G 256GB 1 év Garanciával
- Intel Processzorok sok db : Xeon E5-1620V3, Pentium G4400T, i3 6100, i3-4130, i3-2140T
Állásajánlatok
Cég: FOTC
Város: Budapest