Jump to content
php.lv forumi

curl & POST


hoho

Recommended Posts

Izmantoju Curl lai ar Post metodu nodot datus uz citu web lapu. bet redirekts nenotiek, kaapeec taa?

dalja no koda:

 

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url); // set url to post to

curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);// allow redirects

curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable

curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s

curl_setopt($ch, CURLOPT_POST, 1); // set POST method

curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); // add POST fields

$result = curl_exec($ch); // run the whole process

curl_close($ch);

echo $result;

Link to comment
Share on other sites

tad tieši tā arī dari - saglabā datus pie sevis un ar curl sūti uz ārēju URL. Atceries vien, ka POST curl gadījumā nekādi nenozīmē kaut kādas lietotāja pārsūtīšanas uz citurieni. ja tu gribi pēc tam lietotāju kaut kur redirektēt, tad to pēc curl darbībām vienkārši izdari ar header(location:), piemēram

 

mysql_query("insert into data (val1, val2) values ('a', 'b')");

curl_exec un viss pārējais

header('location: /vieta_kur_parsutit_lietotaju');

Link to comment
Share on other sites

hm, a vispaar nee, nestraadaa kaa vajag, sorry!

man tak jaasuuta tie dati uz $url arii ar POST metodi, lai tas skripts vareetu apstraadaat datus. taapeec Header(Location.... nestraadaa, tas ir tikai redirekts bez POST datiem!

Link to comment
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...
×
×
  • Create New...