By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,377 Members | 3,052 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,377 IT Pros & Developers. It's quick & easy.

Queing Messages For SMS Gateway API

P: 6
I am developing an application that sends different messages to different recipients.The phone numbers and messages are stored in a table,and i use the curl function in a loop to call the API url.The issue is that after the first 10 (or so numbers),the maximum execution time parameter is exceeded,and not all numbers are sent.The support staff of the gateway company said i should try queuing the messages so that i could send them in bulk instead of looping.From the API i know that i can send messages to multiple recipients by separating each number with a comma,so i figure that issue is handled if i implode the array containing the phone numbers.The issue is how to handle the messages in the message array to deliver different messages to different numbers.Or rather,how do i que the numbers and messages so that everything is delivered in bulk to the API?. Below is an excerpt from my code:

Expand|Select|Wrap|Line Numbers
  1. while($launch_row=mysqli_fetch_assoc($launch_result))
  2.   {
  3. $number=$launch_row['phone_number'];
  4. $message=$launch_row['message'];
  5. $url="http://xxxxxxxxxxx?username=yy&password=yyy&type=0&dlr=1&destination=".urlencode($number)."&source=xxx&message=".urlencode($message);
  6.  $ch = curl_init();
  7.  _setopt($ch, CURLOPT_URL, $url);
  8.  curl_setopt($ch, CURLOPT_HEADER, 0);
  9.  $results = curl_exec($ch);
  10.      }
  11.  
Feb 2 '12 #1
Share this Question
Share on Google+
1 Reply


YarrOfDoom
Expert 100+
P: 1,247
As it looks now, it seems your code waits for the API request to finish before continuing on to the next number. By creating all requests first then executing them all at once this problem would be eliminated.

I believe the curl_multi_* functions can help you with this.
Feb 16 '12 #2

Post your reply

Sign in to post your reply or Sign up for a free account.