отправка sms c сайта ? как организовать чтоб смски приходили от имени?

Discussion in 'PHP' started by ufalog, 28 Oct 2007.

  1. ufalog

    ufalog Elder - Старейшина

    Joined:
    28 Jul 2007
    Messages:
    174
    Likes Received:
    6
    Reputations:
    -5
    Cуть---> заходит человек на сайт --->регистрируется( при том указывает свой телефон) --->потом заходит на страничку нажимает кнопочку ---> и ему приходит смс от имени* например site.ru ---> надо чтоб при отправке смс происходило считывание номера указаного при регистрации пользователя и ему приходила смс с определенным текстом....


    как реализовать?
     
  2. Impuls*

    Impuls* Elder - Старейшина

    Joined:
    3 Oct 2007
    Messages:
    75
    Likes Received:
    6
    Reputations:
    -1
    Не знаю точно, поэтому не буду писать :)

    ufalog, буду сильно благодарен и не только я, выложи пожалуйста скрипт отправки смс-ок на разных операторов!! ;)
     
  3. RedBull@12

    RedBull@12 Elder - Старейшина

    Joined:
    5 Nov 2006
    Messages:
    121
    Likes Received:
    21
    Reputations:
    5
    На сколько я знаю что ни один оператор это не делает за спасибо.
    Как вариант можно заюзать SMS-сервис.
    Но это слишком дорогое удовольствие,хотя смотря сколько ты с этого все будешь иметь.
     
  4. SchmeL

    SchmeL Elder - Старейшина

    Joined:
    16 Jun 2007
    Messages:
    64
    Likes Received:
    38
    Reputations:
    5
    а никто не знает скриптов, юзающих смс сервис?
    к примеру на sms.juw.ru подобное
     
  5. mr.The

    mr.The Elder - Старейшина

    Joined:
    30 Apr 2007
    Messages:
    1,080
    Likes Received:
    456
    Reputations:
    38
    там уже можно указать тока номер отправителя... а раньше можно было любое слово указать....

    юзайте кликатель! правда там кредиты покупать нада...
     
  6. Joker-jar

    Joker-jar Elder - Старейшина

    Joined:
    11 Mar 2007
    Messages:
    581
    Likes Received:
    205
    Reputations:
    37
    Почти на всех оф. сайтах операторов есть функция бесплатной отправки смс. Некоторые создают базу этих страниц, полей, необходимых для отправки смс и т.д., потом пишут скрипт, который отправляет смс номеру соответствующего оператора через соответствующую страницу. Можно также сделать определение оператора по нескольким цифрам номера. Я делал только для Мегафон ДВ - sms.kbrdhook.com.

    А чтоб автоматизировать это дело, нужно уже распознование каптчи.
     
  7. Impuls*

    Impuls* Elder - Старейшина

    Joined:
    3 Oct 2007
    Messages:
    75
    Likes Received:
    6
    Reputations:
    -1
    Нет, может у кого есть такой скриптик, распознающий капчу и который не жалко))))
     
  8. onikishov

    onikishov Elder - Старейшина

    Joined:
    25 Mar 2007
    Messages:
    142
    Likes Received:
    74
    Reputations:
    0
    ufalog, в примечании не судьба написать? А сайт по любому будет написан.
     
  9. ufalog

    ufalog Elder - Старейшина

    Joined:
    28 Jul 2007
    Messages:
    174
    Likes Received:
    6
    Reputations:
    -5
    найдено решение мож кому интересно / Clickatell Sms Api

    PHP:
          <?php
          
    /**
          * CLICKATELL SMS API
          *
          * This class is meant to send SMS messages via the Clickatell gateway
          * and provides support to authenticate to this service and also query
          * for the current account balance. This class use the fopen or CURL module
          * to communicate with the gateway via HTTP/S.
          *
          * For more information about CLICKATELL service visit http://www.clickatell.com
          *
          * @version 1.3d
          * @package sms_api
          * @author Aleksandar Markovic <mikikg@gmail.com>
          * @copyright Copyright © 2004, 2005 Aleksandar Markovic
          * @link http://sourceforge.net/projects/sms-api/ SMS-API Sourceforge project page
          * @license http://opensource.org/licenses/gpl-license.php GNU Public License
          *
          */

          /**
          * Main SMS-API class
          *
          * Example:
          * <code>
          * <?php
          * require_once ("sms_api.php");
          * $mysms = new sms();
          * echo $mysms->session;
          * echo $mysms->getbalance();
          * $mysms->send ("38160123", "netsector", "TEST MESSAGE");
          * ?>
          * </code>
          * @package sms_api
          */

          
    class sms {

              
    /**
              * Clickatell API-ID
              * @link http://sourceforge.net/forum/forum.php?thread_id=1005106&forum_id=344522 How to get CLICKATELL API ID?
              * @var integer
              */
              
    var $api_id "YOUR_CLICKATELL_API_NUMBER";

              
    /**
              * Clickatell username
              * @var mixed
              */
              
    var $user "YOUR_CLICKATELL_USERNAME";

              
    /**
              * Clickatell password
              * @var mixed
              */
              
    var $password "YOUR_CLICKATELL_PASSWORD";

              
    /**
              * Use SSL (HTTPS) protocol
              * @var bool
              */
              
    var $use_ssl false;

              
    /**
              * Define SMS balance limit below class will not work
              * @var integer
              */
              
    var $balace_limit 0;

              
    /**
              * Gateway command sending method (curl,fopen)
              * @var mixed
              */
              
    var $sending_method "fopen";

              
    /**
              * Optional CURL Proxy
              * @var bool
              */
              
    var $curl_use_proxy false;

              
    /**
              * Proxy URL and PORT
              * @var mixed
              */
              
    var $curl_proxy "http://127.0.0.1:8080";

              
    /**
              * Proxy username and password
              * @var mixed
              */
              
    var $curl_proxyuserpwd "login:secretpass";

              
    /**
              * Callback
              * 0 - Off
              * 1 - Returns only intermediate statuses
              * 2 - Returns only final statuses
              * 3 - Returns both intermediate and final statuses
              * @var integer
              */
              
    var $callback 0;

              
    /**
              * Session variable
              * @var mixed
              */
              
    var $session;

              
    /**
              * Class constructor
              * Create SMS object and authenticate SMS gateway
              * @return object New SMS object.
              * @access public
              */
              
    function sms () {
                  if (
    $this->use_ssl) {
                      
    $this->base   "http://api.clickatell.com/http";
                      
    $this->base_s "https://api.clickatell.com/http";
                  } else {
                      
    $this->base   "http://api.clickatell.com/http";
                      
    $this->base_s $this->base;
                  }

                  
    $this->_auth();
              }

              
    /**
              * Authenticate SMS gateway
              * @return mixed  "OK" or script die
              * @access private
              */
              
    function _auth() {
                  
    $comm sprintf ("%s/auth?api_id=%s&user=%s&password=%s"$this->base_s$this->api_id$this->user$this->password);
                  
    $this->session $this->_parse_auth ($this->_execgw($comm));
              }

              
    /**
              * Query SMS credis balance
              * @return integer  number of SMS credits
              * @access public
              */
              
    function getbalance() {
                  
    $comm sprintf ("%s/getbalance?session_id=%s"$this->base$this->session);
                  return 
    $this->_parse_getbalance ($this->_execgw($comm));
              }

              
    /**
              * Send SMS message
              * @param to mixed  The destination address.
              * @param from mixed  The source/sender address
              * @param text mixed  The text content of the message
              * @return mixed  "OK" or script die
              * @access public
              */
              
    function send($to=null$from=null$text=null) {

                  
    /* Check SMS credits balance */
                  
    if ($this->getbalance() < $this->balace_limit) {
                      die (
    "You have reach the SMS credit limit!");
                  };

                  
    /* Check SMS $text length */
                  
    if (strlen ($text) > 465) {
                      die (
    "Your message is to long! (Current lenght=".strlen ($text).")");
                  }

                  
    /* Does message need to be concatenate */
                  
    if (strlen ($text) > 160) {
                      
    $concat "&concat=3";
                  } else {
                      
    $concat "";
                  }

                  
    /* Check $to and $from is not empty */
                  
    if (empty ($to)) {
                      die (
    "You not specify destination address (TO)!");
                  }
                  if (empty (
    $from)) {
                      die (
    "You not specify source address (FROM)!");
                  }

                  
    /* Reformat $to number */
                  
    $cleanup_chr = array ("+"" ""("")""\r""\n""\r\n");
                  
    $to str_replace($cleanup_chr""$to);

                  
    /* Send SMS now */
                  
    $comm sprintf ("%s/sendmsg?session_id=%s&to=%s&from=%s&text=%s&callback=%s%s",
                      
    $this->base,
                      
    $this->session,
                      
    rawurlencode($to),
                      
    rawurlencode($from),
                      
    rawurlencode($text),
                      
    $this->callback,
                      
    $concat
                  
    );
                  return 
    $this->_parse_send ($this->_execgw($comm));
              }

              
    /**
              * Execute gateway commands
              * @access private
              */
              
    function _execgw($command) {
                  if (
    $this->sending_method == "curl")
                      return 
    $this->_curl($command);
                  if (
    $this->sending_method == "fopen")
                      return 
    $this->_fopen($command);
                  die (
    "Unsupported sending method!");
              }

              
    /**
              * CURL sending method
              * @access private
              */
              
    function _curl($command) {
                  
    $this->_chk_curl();
                  
    $ch curl_init ($command);
                  
    curl_setopt ($chCURLOPT_HEADER0);
                  
    curl_setopt ($chCURLOPT_RETURNTRANSFER,1);
                  
    curl_setopt ($chCURLOPT_SSL_VERIFYPEER,0);
                  if (
    $this->curl_use_proxy) {
                      
    curl_setopt ($chCURLOPT_PROXY$this->curl_proxy);
                      
    curl_setopt ($chCURLOPT_PROXYUSERPWD$this->curl_proxyuserpwd);
                  }
                  
    $result=curl_exec ($ch);
                  
    curl_close ($ch);
                  return 
    $result;
              }

              
    /**
              * fopen sending method
              * @access private
              */
              
    function _fopen($command) {
                  
    $result '';
                  
    $handler = @fopen ($command'r');
                  if (
    $handler) {
                      while (
    $line = @fgets($handler,1024)) {
                          
    $result .= $line;
                      }
                      
    fclose ($handler);
                      return 
    $result;
                  } else {
                      die (
    "Error while executing fopen sending method!<br>Please check does PHP have OpenSSL support and check does PHP version is greater than 4.3.0.");
                  }
              }

              
    /**
              * Parse authentication command response text
              * @access private
              */
              
    function _parse_auth ($result) {
                  
    $session substr($result4);
                  
    $code substr($result02);
                  if (
    $code!="OK") {
                      die (
    "Error in SMS authorization! ($result)");
                  }
                  return 
    $session;
              }

              
    /**
              * Parse send command response text
              * @access private
              */
              
    function _parse_send ($result) {
                  
    $code substr($result02);
                  if (
    $code!="ID") {
                      die (
    "Error sending SMS! ($result)");
                  } else {
                      
    $code "OK";
                  }
                  return 
    $code;
              }

              
    /**
              * Parse getbalance command response text
              * @access private
              */
              
    function _parse_getbalance ($result) {
                  
    $result substr($result8);
                  return (int)
    $result;
              }

              
    /**
              * Check for CURL PHP module
              * @access private
              */
              
    function _chk_curl() {
                  if (!
    extension_loaded('curl')) {
                      die (
    "This SMS API class can not work without CURL PHP module! Try using fopen sending method.");
                  }
              }
          }

          
    ?>

     
  10. nc.STRIEM

    nc.STRIEM Members of Antichat

    Joined:
    5 Apr 2006
    Messages:
    1,036
    Likes Received:
    347
    Reputations:
    292
    это платные смс.
     
  11. _Sniper_

    _Sniper_ Banned

    Joined:
    21 Jul 2007
    Messages:
    409
    Likes Received:
    147
    Reputations:
    -17
    Тебе для каких операторов? Страну гри. Если для России то нету..
     
    1 person likes this.
  12. Impuls*

    Impuls* Elder - Старейшина

    Joined:
    3 Oct 2007
    Messages:
    75
    Likes Received:
    6
    Reputations:
    -1
    А есть скрипты, отправляющие смс-ки через сайт оператора? :)
    У кого есть рабочие, дайте плиз! С меня ++++++ :)
     
  13. SchmeL

    SchmeL Elder - Старейшина

    Joined:
    16 Jun 2007
    Messages:
    64
    Likes Received:
    38
    Reputations:
    5
    ну вот к примеру модуль (блок) для какой-то цмс-ки если доработать (форму нормальную сделать), то полноценный модуль http://slil.ru/25043240
     
  14. _Great_

    _Great_ Elder - Старейшина

    Joined:
    27 Dec 2005
    Messages:
    2,032
    Likes Received:
    1,118
    Reputations:
    1,139
    некоторые операторы предоставляют услугу email to sms. посылается емейл на определенный адрес, который потом транслируется в смс.
    например, на билайне она сть и бесплатная, но ее нужно отдельно подключать
     
  15. Impuls*

    Impuls* Elder - Старейшина

    Joined:
    3 Oct 2007
    Messages:
    75
    Likes Received:
    6
    Reputations:
    -1
    Это лично я знаю :)
    и это не подойдет, а так удобная фишка)