Loading ...
Sorry, an error occurred while loading the content.

Re: How can I send sms through PHP

Expand Messages
  • maq005
    Hey Madhur, To send sms you need a sms gateway, which will forword your sms to the users. Please google for that...... Am work on sms handling these days on
    Message 1 of 3 , Jul 2, 2007
    • 0 Attachment
      Hey Madhur,

      To send sms you need a sms gateway, which will forword your sms to the
      users. Please google for that......

      Am work on sms handling these days on Mytoday project. We have
      recently launched product called MOBS please have a look at
      pub.mytoday.com.

      Coming back to your question, sending sms all depends on which service
      provider or gateway you choose. The format of sending data differs.

      There are two which I know ACL and Value First please google for details.


      Here is the simple function :


      //Send the messages using the VF gateway function vf_sendsms ($nums,
      $msg) { $start = time(); $post_location = 'url from VF';
      $host = 'url from VF'; $port = '80'; $from = 'your
      address'; $send_msg = utf8_encode(htmlspecialchars($msg));
      $hash_seed = $start.mt_rand().$msg; $msgid = md5($hash_seed);
      $phone_nums = ''; foreach ($nums as $n) { $phone_nums .=
      '<ADDRESS FROM="'.$from.'" TO="'.$n.'" SEQ="'.$n.'" TAG="" />'; }
      $query_string = 'data=<?xml version="1.0"
      encoding="ISO-8859-1"?><!DOCTYPE Messaging SYSTEM
      "http://127.0.0.1/psms/dtd/message.dtd" ><MESSAGE><USER
      USERNAME="yourname" PASSWORD="shnetkk67"/><SMS UDH="0" CODING="1"
      TEXT="'.$send_msg.'" PROPERTY="0"
      ID="'.$msgid.'">'.$phone_nums.'</SMS></MESSAGE>&action=send';
      $http_request = "POST ".$post_location." HTTP/1.0\r\n";
      $http_request .= "Host: ".$host."\r\n"; $http_request .=
      'Content-Type: application/x-www-form-urlencoded'."\r\n";
      $http_request .= 'Content-Length: ' . strlen($query_string) . "\r\n";
      $http_request .= 'User-Agent: Your address' . "\r\n";
      $http_request .= "\r\n"; $http_request .= $query_string;
      $response = ''; if ( false
      !== ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
      fwrite($fs, $http_request); while ( !feof($fs) )
      $response .= fgets($fs, 4096); fclose($fs); $response =
      explode("\r\n\r\n", $response, 2); $body = trim( $response[1]
      ); $body = str_replace(array("\r\n", "\r"), "\n", $body);
      $xml = new SimpleXMLElement($body); if(isset($xml->Err)) {
      //Get the error code and dump the message in the log
      foreach($xml->Err->attributes() as $b) { $errmsg .= "\t".$b; } $log
      = "[tool: Send Test SMS - VF]\t[query: $query_string]\t".$errmsg;
      $util->log($log, 'CRIT', 'ADMIN'); print '<span
      class="red">The message could not be sent. Please check if the format
      of your message is correct.</span>'; return 0; }
      elseif(isset($xml->GUID) ) { $data['nums'] =
      serialize($nums); $data['msg'] = $msg;
      foreach($xml->GUID->attributes() as $b) { $successmsg .= "\t".$b; }
      $log = "[tool: Send Test SMS - VF]\t[query:
      $query_string]\t".$successmsg; $util->log($log, 'INFO',
      'ADMIN'); print '<span class="red">The message was
      successfully sent.</span>'; return 1; } }
      else { print '<span class="red">The messages could not be sent
      as there was an error connecting to the gateway.'; return 2;
      } }

      2) On which event i have to send it(there is no admin click and any
      other event. admin just save the message body.)

      I suggest you to use cron job which will take the message and send sms
      on specfic time.

      3) How to send sms according to the time zone.

      As I have said earlier, SMS gateway check out with them if you can
      send international sms and about timezone I havn't worked no it I
      think that shud be simple by setting the time zone based on country.


      Hope that helps you. Please lemme know for any clarification.


      Regards,
      Mohammed Maqsood




      --- In bang-phpug@yahoogroups.com, "madhur_gemini" <madhur_gemini@...>
      wrote:
      >
      > Dear Member,
      >
      > I need your help, i have assigned a difficult(for me) task.
      >
      > Can any one tell me the procedure how can we send worldwide sms
      > through php.
      >
      > Sms should be sent according to the time zone and in everycountry
      > every subscribers got sms at 9 AM in morning.
      >
      > My Queries are:
      >
      > 1) How to send sms(is it possible in php)?
      > 2) On which event i have to send it(there is no admin click and any
      > other event. admin just save the message body.)
      > 3) How to send sms according to the time zone.
      >
      > Anybody please advice me.
      >
      > Thanks
      > Madhukar Garg
      > madhur_gemini@...
      >
    • prashant rahulkar
      Dear Friend, Everything is possible in PHP , if you want to send SMS using php Used the CURL library. Regards Prashant Rahulkar ... From: madhur_gemini
      Message 2 of 3 , Jul 26, 2007
      • 0 Attachment
        Dear Friend,
        Everything is possible in PHP , if you want to send SMS using php
        Used the CURL library.

        Regards
        Prashant Rahulkar





        ----- Original Message ----
        From: madhur_gemini <madhur_gemini@...>
        To: bang-phpug@yahoogroups.com
        Sent: Saturday, 30 June, 2007 6:10:23 PM
        Subject: [bang-phpug] How can I send sms through PHP

        Dear Member,

        I need your help, i have assigned a difficult(for me) task.

        Can any one tell me the procedure how can we send worldwide sms
        through php.

        Sms should be sent according to the time zone and in everycountry
        every subscribers got sms at 9 AM in morning.

        My Queries are:

        1) How to send sms(is it possible in php)?
        2) On which event i have to send it(there is no admin click and any
        other event. admin just save the message body.)
        3) How to send sms according to the time zone.

        Anybody please advice me.

        Thanks
        Madhukar Garg
        madhur_gemini@ yahoo.co. in





        Download prohibited? No problem. CHAT from any browser, without download. Go to http://in.messenger.yahoo.com/webmessengerpromo.php/

        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.