Current location: Hot Scripts Forums » Programming Languages » PHP » Another cURL problem :(


Another cURL problem :(

Reply
  #1 (permalink)  
Old 01-27-09, 08:38 PM
arshem arshem is offline
New Member
 
Join Date: Jan 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Another cURL problem :(

Hey Everyone!

I'm having a cURL problem. basically i am looking at this

I'm trying to download a video from a website. It is free for members, and i am a member, however i would like to download them automatically through curl [i believe this would be the best way to do it].

here is what i have:

Code:
    $values = form_handle_input("videos_import_url");



		/////////////////////////////////////////////////////////

		$LOGINURL = "http://www.DOMAIN.com/login.php";
		$id = "USER"; $password = "PASS";
		$POSTFIELDS = 'username='.$id.'&password='.$password;
		$agent = "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.5) Gecko/2008120122 Firefox/3.0.5"; 
		$reffer = "http://www.ORIGINALDOMAIN.com";

        $hash = build_unique_path(DOC_ROOT."/vid",".flv");
		$dist_file = DOC_ROOT."/vid/".$hash.".flv";

	    $flash = fopen( $dist_file, 'wb' );

		$curl = curl_init();
		curl_setopt($curl, CURLOPT_URL, $values["url"]);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
		curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie.txt");
		$url = curl_exec($curl);
		curl_setopt($curl, CURLOPT_URL,$LOGINURL); 
		curl_setopt($curl, CURLOPT_USERAGENT, $agent);
		curl_setopt($curl, CURLOPT_POST, 1);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $POSTFIELDS); 
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
		curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1); 
		curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie.txt");
		$store = curl_exec ($curl);
		curl_setopt($curl, CURLOPT_URL,$values["video"]);
		curl_setopt($curl, CURLOPT_REFERER, $values["url"]);
		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); 
		curl_setopt($curl, CURLOPT_USERAGENT, $agent);
		curl_setopt($curl, CURLOPT_COOKIE, 1);
		curl_setopt($curl, CURLOPT_COOKIESESSION, TRUE);
		curl_setopt($curl, CURLOPT_COOKIEJAR, "cookie.txt");
		$flv = curl_exec($curl);
//		print($flv);exit;		
		fwrite($flash,$flv);
		fclose($flash);

	    curl_close($curl);
		///////////////////////////////////////////////////////

But i get a 403 error. [i find this out by editting the flv that is saved]. I can download images this way on the same server, but the videos are probably a little more advanced. Any ideas ? As you can see i'm already trying to make my curl be a "browser" with cookies and referer and still no good


Thanks in advance!

brandon
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
login, roles problem dbrook007 ASP.NET 10 11-10-06 03:42 PM
Form Display Problem neevrap02 Visual Basic 1 09-05-06 05:18 AM
curl problem d*d PHP 2 05-23-05 08:41 AM
Count problem kasic ASP.NET 1 10-20-04 12:23 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 09:13 AM


All times are GMT -5. The time now is 08:27 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.