Jump to content
php.lv forumi
Sign in to follow this  
sandis_m

cURL

Recommended Posts

Visādi izmēģinājos, google arī šoreiz ne visai.

 

 


$ch = curl_init();


//get
curl_setopt($ch, CURLOPT_POST, 0);
curl_setopt($ch, CURLOPT_URL, "http://example.lv/");
$dra = curl_exec ($ch);

//preg_match(etc and other stuff);
//array_shift($matches);
//#print_r($matches);
//$pwn = $matches[0];



curl_setopt($ch, CURLOPT_URL, "http://example.lv/index.php");
curl_setopt ($ch, CURLOPT_POSTFIELDS, "redir=%2F&email=". urlencode($em) ."&$password=". urlencode($pass) ."&login=go");
curl_setopt ($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt ($ch, CURLOPT_COOKIEJAR, "cookie.txt");
curl_setopt($ch, CURLOPT_COOKIEFILE, "cookie.txt");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.3) Gecko/20070309 Firefox/2.0.0.3");
$es = curl_exec ($ch);	

echo $es;

Share this post


Link to post
Share on other sites

Šodien labs garīgais:

 

CURLOPT_FOLLOWLOCATION << TRUE

 

Nu, man jau ir viņš tā uzstādīts, bet no tā nekas nemainās

 

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

Share this post


Link to post
Share on other sites

who_i_am: lasi uzmanīgāk manuāli:

value should be a bool for the following values of the option parameter:

...

CURLOPT_FOLLOWLOCATION TRUE to follow any "Location: " header that the server sends as part of the HTTP header

iespējams, ka tāpēc arī nestrādā. 1 !== TRUE

Share this post


Link to post
Share on other sites

Tātad, pareizi būtu:

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

?

 

 

--

 

nu, bet izmet atkal:

 

301 Moved Permanently

 

nginx/0.9.2

Edited by who_i_am

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...