Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 30th, 2012  |  syntax: None  |  size: 0.68 KB  |  hits: 45  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Sending SMS AT commands to 3G modem using PHP
  2. <?
  3. exec("mode COM5 BAUD=9600 PARITY=N data=8 stop=1 xon=off");
  4. $fp = fopen ("\.COM5:", "r+");
  5. //$fp = dio_open('COM5:', O_RDWR | O_NOCTTY | O_NONBLOCK);
  6. if (!$fp)
  7. {
  8.     echo "Uh-oh. Port not opened.";
  9. }
  10. else
  11. {
  12.  
  13.     $string  = "AT+CMGF=1";
  14.  
  15.     $string  = $string."OK";
  16.  
  17.     $string  = $string."AT+CMGS='+27824139864'";
  18.  
  19.     $string  = $string."> Hello World?<Ctrl>+<Z>";
  20.  
  21.     $string  = $string."+CMGS: 44";
  22.  
  23.     $string  = $string."OK";
  24.  
  25.     fputs ($fp, $string );
  26.     echo $string."n";
  27.     fclose ($fp);
  28. }
  29.  
  30. ?>
  31.        
  32. 1 second delay
  33. +++
  34. 1 second delay
  35. The modem should respond with "OK"
  36. Type AT+CMGF=1
  37. press enter key
  38. Modem will repond with "OK"