Hi,
I have a php phone app (click to call sort of thing) I'm writing that sends data filled in via a form and sends it to another server which places the phone call. The phone server api suggests to use the curl function to send the url with the data appended in the query string. That's fine and all, but when I use curl to send that url, my submission page hangs until the call connects. So in other words, here is the process:
1. Form page -> 2. Page where I do validation and initiate the curl -> 3. Success page shown to person who filled the form
To get around the problem I encountered with waiting for the call to connect, I created a new page with the curl function. Then in step 2, I use the fsockopen to process that new page. Now the form user gets right to the submission page quickly since the curl process is carried out in the background.
So my question? Is this the right way to be doing things? Is there a better way and maybe better yet, is this secure?
Thanks!
b
Using the curl function is slowing my app down
Moderator: General Moderators
Re: Using the curl function is slowing my app down
Don't really know what you are doing here. There are some timeout options here that might help:
http://uk.php.net/manual/en/function.curl-setopt.php
Additionally, I have made an OO cURL class that might help you.
http://uk.php.net/manual/en/function.curl-setopt.php
Additionally, I have made an OO cURL class that might help you.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Re: Using the curl function is slowing my app down
PHP is probably not the best tool for this. As you have managed to discover, expensive operations are better handled in the background by a daemon. I would either suggest a cron job to pick up pending tasks if the operation is not time critical, or implement some sort of multi-threaded application residing on the server to accept requests on the go.
Reguardless, depending how important this is to you, your current implementation should be ok. I just wouldn't expect it to scale very well.
Reguardless, depending how important this is to you, your current implementation should be ok. I just wouldn't expect it to scale very well.
Re: Using the curl function is slowing my app down
Thanks for your answers guys. I'll look into deploying a cron job.