Jump to content

get info with cURL and post it


mysterbx

Recommended Posts

hi,

 

Can curl get info from a page, and post it (postields) without reloading the page?

 

Here is an example:

 

$user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_FAILONERROR, 1);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch1, CURLOPT_PORT, 80);
curl_setopt($ch1, CURLOPT_TIMEOUT, 5);
curl_setopt($ch1, CURLOPT_USERAGENT, $user_agent);
$r1 = curl_exec($ch1);
while ($r1) {
preg_match("#\<input type=\"hidden\" name=\"ses\" value=\"([\d\w]+?)\"\>#ise", $r1, $one);
preg_match("#\<input type=\"hidden\" name=\"time\" value=\"([\d\w\.]+?)\"\>#ise", $r1, $two);
$params = "ses=".one[2]."&time=two[2]&name=curl";
}
curl_setopt($ch1, CURLOPT_POST,1);
curl_setopt($ch1, CURLOPT_POSTFIELDS,$params);
curl_exec($ch1);

 

page loads, curl gets info, and post's it without reloading the page (I dont know if I used the "while" function correctly)

Link to comment
Share on other sites

I'm fairly new to php so I'm not sure if there's a way to do it with php (although I don't think so and I don't see how). I think you should probably look into using AJAX - which would involve buying a book and learning it... AJAX is a scripting method that merges the DOM, standards based presentation and javascript - in effect, it ends up loading everything in the background so no refresh is needed and there is virtually no lag time (like when you move the map around in Google Maps).

Good luck!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.