Jump to content

Curl: Object Moved Error..?


cyfer65

Recommended Posts

I made a PHP curl page that works ok, but with some URLs it gives me an "Object Moved, This document may be found here" with a link to go to the site the original URL is forwarding to..so my question is how can i make the php page get that new URL & then curl it..??

Link to comment
Share on other sites

how exactly could i do that..??Is there a way to first check the URL to see if it redirects to another site & if it does then use that URL for the CURL job..??this is my php code so far.. what can I add or change to make it check the URL first before it does the CURL process..??

<?php$Link = $_SERVER['QUERY_STRING'];$uri = parse_url($Link);$base = "http://".$uri[host]."";	echo geturl($Link, $base);	function geturl($url, $referer) { 		$headers[] = 'Accept: image/png, image/gif, image/x-bitmap, image/jpeg, image/pjpeg'; 		$headers[] = 'Connection: Keep-Alive'; 		$headers[] = 'Content-type: application/x-www-form-urlencoded;charset=UTF-8'; 		$UserAgent = 'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0)'; 		$process = curl_init($url); 		curl_setopt($process, CURLOPT_HTTPHEADER, $headers); 		curl_setopt($process, CURLOPT_HEADER, 0); 		curl_setopt($process, CURLOPT_USERAGENT, $UserAgent);		curl_setopt($process, CURLOPT_REFERER, $referer);		curl_setopt($process, CURLOPT_TIMEOUT, 60); 		curl_setopt($process, CURLOPT_RETURNTRANSFER, 1); 		curl_setopt($process, CURLOPT_FOLLOWLOCATION, 1); 		$return = curl_exec($process);		curl_close($process); 		return $return; 	} ?>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...