Link to home
Start Free TrialLog in
Avatar of XK8ER
XK8ERFlag for United States of America

asked on

request page using curl

hello there,
I am using curl for my forum to verify download links from free hosting services..
i am having trouble trying to verify a site that has cookie in order to verify if the file
exists or has been deleted.. if you dont accept cookies you will get the same page
even though the file doesnt exist.. but if you accept cookies the page will show file
does not exist. im trying to fix this code and make it work..
function curl($link, $post='0')
{
    if($fgc == 1)
	{
        file_get_contents($link);        
	}
    else
	{
		$ch = curl_init($link);
		curl_setopt($ch, CURLOPT_HEADER, 0);
	    if(eregi("megashares\.com" , $link))
		{
        curl_setopt($ch, CURLOPT_COOKIE, 1);
        curl_setopt($ch, CURLOPT_COOKIEJAR, 1);
        curl_setopt($ch, CURLOPT_COOKIEFILE, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		}
				curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
				curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
		if($post != '0')
		{
				curl_setopt($ch, CURLOPT_POST, 1);
				curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
		}
		$page = curl_exec($ch);
		echo $page;
		return($page);
				curl_close($ch);
	}
}

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of agamal
agamal
Flag of United Arab Emirates image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial