I am trying to do the following
$url = "http://halo-video.com/drama/ha"; $data = file_get_contents($url); echo $data; it give me a blank page or a 500 internal error, I tried load the site with my computer, and its load fine.
although reason could be different but my code (similar to yours) works fine so just append these lines into yours at appropriate places,
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; nl; rv:1.9.1.7) Gecko/20091221 Firefox/3.5.7"; curl_setopt($s,CURLOPT_AUTOREFERER, true); curl_setopt($s,CURLOPT_FOLLOWLOCATION, true); curl_setopt($s,CURLOPT_MAXREDIRS, 5); curl_setopt($s,CURLOPT_RETURNTRANSFER, true); curl_setopt($s, CURLOPT_HEADER, true); EDIT:
Ok, this was bugging me so figured out a fix.
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://kissanime.com/Anime/Karneval'); curl_setopt($ch, CURLOPT_USERAGENT, 'myuseragent'); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30); curl_setopt($ch, CURLOPT_REFERER, "http://www.test.com"); $html = curl_exec($ch); curl_close($ch); echo $html; This code works and fixed the redirect errors I was getting. Happy content grabbing.
kissanime.comdomain because I replaced the URL with Google's and it worked fine (code).