Page 1 of 1

Post/Ping to a URL without waiting for a result

Posted: Tue May 29, 2007 4:24 am
by sampsas
Basically the public can submit events.

The public can sign up to be notified everytime an event is approved.

Admin user goes in and approves which ever events are submitted.

So when the admin user approves the event, I want to "ping" / "post" / "touch" (not sure of technical term) a url that actually sends out the mailout to those who want to be notified. But I do NOT want to wait for results as it could take a long time to send out all the emails. So after "pinging" the url, the admin user is taken to back to the event listings page to be able to approve more.

Is there a way to just make "ping" a url and not wait for results and just keep going?

Posted: Tue May 29, 2007 8:25 am
by feyd
cURL, possibly other libraries, supports setting a timeout.

Timeout

Posted: Thu May 31, 2007 7:52 am
by sampsas
Thanks for your reply.

I can't seem to get it to work though - it doesn't timeout.

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT,2);
$data = curl_exec($ch);
curl_close($ch);

Am I missing a step?
Or maybe 2 seconds is too short?

I tried to look for timeout options, maybe I another one?

Or maybe i need to do something special after a timeout?

Any help would be appreciated.

Thanks.

Posted: Thu May 31, 2007 8:02 am
by feyd
I've never needed to use the timeout features.

There appear to be several options concerning timeouts and time limits. Have you tried combinations of those? An alternate may be to create a non-blocking socket.

Posted: Thu May 31, 2007 8:13 am
by phpdevuk
what about using ajax to call a script on the server?

Posted: Thu May 31, 2007 8:26 am
by feyd
phpdevuk wrote:what about using ajax to call a script on the server?
While many would likely do this, I wouldn't. I don't consider requiring Javascript enabled (let alone supports Ajax) a good route where the function of the system would fail because it was disabled.