1

when I approve an order, it redirects to a confirmation page which adds details to dbase, send email etc... Now, I want that to also send sms automatically by loading the gateway url the url open in browser but I want it to run in the background.

For now, I put a link where I click and it opens in new browser...

Please help

Naira4Dollar
  • 17
  • 2
  • 4

4 Answers4

3

If I understand correctly you send the SMS by opening an URL. You could achieve this by opening the url with cURL in a php file:

// create a new cURL resource
$ch = curl_init();

// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, "http://www.example.com/");

// grab URL and pass it to the browser
curl_exec($ch);

// close cURL resource, and free up system resources
curl_close($ch);

for more info see: http://php.net/manual/en/function.curl-setopt.php

DivZero
  • 2,438
  • 2
  • 24
  • 23
  • 1
    @Naira Alternatively, if the SMS-sending page takes some time to load and you don't want your page to be delayed by that, you could run something like `exec("wget '$url' > /dev/null");`, assuming your server runs on linux (redirecting output anywhere makes `exec` to run in background, without hanging PHP until the program finishes). – Slava May 15 '11 at 19:19
  • I tried the curl and sure it could have worked cos the gateway returned code 1800 which means sms not sent. I coped the exact url into my browser and got code 1801 which means message sent and I received the message. What do you think could be left? – Naira4Dollar May 15 '11 at 20:46
  • I also tried the exec() and got this response "Warning: exec() has been disabled for security reasons in /home/xxxx/public_html/allnews.php on line 23 " – Naira4Dollar May 15 '11 at 20:47
  • thanks a lot for this answer... you made my day... i was able to execute and send msg via this script... Note: the message should have every space replaced with '%20'... else will throw bad response.. thanks! – Samuel Mathews Aug 02 '14 at 09:29
1

See Asynchronous PHP calls - this should be what you need.

Community
  • 1
  • 1
Tadeck
  • 132,510
  • 28
  • 152
  • 198
0

You can use Tasks module for delayed (background) execution.
You can put there sms and email sending, and your main page will not have to wait their execution.

OZ_
  • 12,492
  • 7
  • 50
  • 68
  • Not sure about Windows because Task manager should be launched by cron or something else (task scheduler in windows, I guess). – OZ_ Feb 07 '13 at 14:58
0

It may not be what your looking for but is worth mentioning. Why dont you just CC the email to your carriers SMS email?

T-Mobile: phonenumber@tmomail.net
Virgin Mobile: phonenumber@vmobl.com
Cingular: phonenumber@cingularme.com
Sprint: phonenumber@messaging.sprintpcs.com
Verizon: phonenumber@vtext.com
Nextel: phonenumber@messaging.nextel.com

Ryan Cooper
  • 703
  • 3
  • 11
  • 23
  • HA, IDK. Thats under the assumption his carrier is a main US company, and the texts are for his own usage and not a user. – Ryan Cooper May 15 '11 at 19:52