• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 337
  • Last Modified:

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

0
XK8ER
Asked:
XK8ER
1 Solution
 
agamalCommented:
seems like working code to me

i added to tries at the end try it your self ...

<?php
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);
        }
}
//not working
curl('http://d01.megashares.com/?d01=41614f7');
//working
//curl('http://d01.megashares.com/?d01=b652976');
 
 
?>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now