How can i do this using curl instead of file _get_contents

Discussion in 'PHP' started by baris22, May 29, 2010.

  1. #1
    
    
    function rs_check($url){
    	if (!$url) return false;
    	$files_pattern= '/\/files\/([^\/]*)\//';
    	$filename_pattern= '/\/files\/.*\/(.*)/';
    	preg_match($files_pattern, $url, $matches_id);
    	preg_match($filename_pattern, $url, $matches_name);
    	$res= file_get_contents("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files={$matches_id[1]}&filenames={$matches_name[1]}");
    	list($fId,$fName,$fSize,$fServerId,$fStatus,$fShortHost,$fmd5) =explode(',',$res);
    	return ($fStatus==1 || $fStatus==2);
    }
    
    
    
    PHP:

     
    baris22, May 29, 2010 IP
  2. tolra

    tolra Active Member

    Messages:
    515
    Likes Received:
    36
    Best Answers:
    1
    Trophy Points:
    80
    #2
    Replace file_get_contents line with:
    $ch = curl_init("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files={$matches_id[1]}&filenames={$matches_name[1]}");
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $res = curl_exec($ch);
    curl_close($ch);
    PHP:
     
    tolra, May 29, 2010 IP