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
https://forums.phpfreaks.com/topic/90230-get-info-with-curl-and-post-it/
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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.