Okay... Im new to using CURL so i hope someone will help me. Basically I need to download remote file to the directory on my server. My script is doing a search across titles in database, then take from it their id and pass it to $aid variable. Rest is in snippet: function get_contents($url) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_PORT,9001); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_ENCODING, "utf-8"); $string = curl_exec($ch) or die(curl_error()); curl_close($ch); return $string; } ...blablabla $adres = 'http://api.anidb.net9001/httpapi?request=anime&client=animerank&clientver=1&protover=1&aid='.$aid; $con = get_contents($adres); $had = './aid_xml/'.$aid.'.xml'; $ha = fopen($had,"w"); fputs($ha,$con); fclose($ha); ..rest PHP: Unfortunately im not geting normal file like i would typing for example http://api.anidb.net:9001/httpapi?request=anime&client=animerank&clientver=1&protover=1&133 in my browser. Instead contents are standard 404 page. I believe that is the page received if not connected on 9001 port. But I think I done this part with curl curl_setopt($ch,CURLOPT_PORT,9001); PHP: What am I doing wrong? Definition of the api: http://wiki.anidb.info/w/HTTP_API_Definition
The URL you gave show this error. If you try with http://api.anidb.net:9001/httpapi?request=anime&client=animerank&clientver=1&protover=1&133&aid=3 it will work.
Thats not the case. I made a mistake posting a link but script still doesnt work. Content is gzipped and utf-8 encoded, but i think Curl decompress gzpipped pages automatically.