Welcome Guest, Not a member yet? Register   Sign In
How to request and url without expect the response
#1

[eluser]Ryubr[/eluser]
Hello,

I have tried to find a solution on the boards, nothing so far. My question is, i have in my Model class one function to add some data to a database and at the end to do a get or post for an external url just to signal it "i did it", but i don't want to expect the answer bacause it could delay the response to the application on my side if the external url is too slow or off-line. Just like ajax, but in this case server side, i would like to send the request and go on without wait for it to finish.

Any ideias about how to do it?

Thanks in advance
#2

[eluser]drewbee[/eluser]
Sure. Check out PHP's exec() function. It lets you drop into the background and execute / run shell commands. In your case, you would want to run a php file. This will execute it in the background while your normal page can go on.

function.exec()

ex.
Code:
exec(escapeshellcmd("php path/to/file -s"))
#3

[eluser]SitesByJoe[/eluser]
You could also use the Curl library to run remote requests. Works well for me!
#4

[eluser]Ryubr[/eluser]
Thanks for the reply, but what i need is something like the curl but that does not "hold" the execution, unfortunatelly i will not be able to use the exec :-(
#5

[eluser]drewbee[/eluser]
Why can you not use exec? That should be available on even a shared server? As well, you could look into forking. The exec should reside on the external server. As curl posts to it, it runs the exec command all the while curl thinks everything is honkey doorey!

Or if you don't have access to the exerternal server, use exec() to issue the curl command out to the external server.




Theme © iAndrew 2016 - Forum software by © MyBB