четверг, 15 декабря 2011 г.

Cкрипт автоматической отправки SMS beeline

Нужно написать скрипт, который будет отправлять автоматически, на один и тот же номер, смс, через определенное время.
header('Content-Type: text/html; charset=utf8');
// ignore_user_abort();



require_once("include/beeline_ru.class.php");
require_once("include/curl.class.php");
require_once("include/recognize.captcha.class.php");


$rc = New RecognitionCaptcha();
$ch = New CurlClass();

$bl = New BeeLineRuClass();
$bl->dirtysmstext = 'Сообщение';
$bl->phone = '79051234567';

$bl->sendSMS();




Функция отправки сообщения
class BeeLineRuClass
 function sendSMS()
 {
  global $ch;
  print "
BeeLineRuClass->sendSMS()
\n";
  $headers = $ch->set_headers();
  #$headers[] = "Expect: ";
  $curl_data['headers'] =  $headers;
  $curl_data['followlocation'] = true;
  $curl_data['echo_header'] = true;

  $curl_data['url'] = "https://www.beeline.ru/sms/index.wbp";
  $curl_data['referer'] = '';

  $this->code = $ch->curl($curl_data);
  $this-> write_string("logs/beeline_index.wbp.html", $this->code);
  //echo $this->code;

  $this-> GetAfCode();
  if($this-> afcode == '')
  {
     echo "return false afcode";
     return false;
  }

  $this-> GetConfirmCode();
  if($this-> confirmcode == '')
  {
    echo "return false confirmcode (capthca)";
    return false;
  }

  if($this-> dirtysmstext)
  {
   $this->smstext = $this-> mso_slug($this-> dirtysmstext);
  }
  else
  {
   echo "return false dirtysmstext";
   return false;
  }


  $this->smsto = substr($this->phone, 4);
  $this->smstoprefix = substr($this->phone, 1, 3);

  $post_data = array
  (
   "afcode" => $this-> afcode,
   "confirm_key" => $this-> confirm_key,
   "confirmcode" => $this-> confirmcode,
   "dirtysmstext" => iconv('utf-8', 'cp1251', $this-> dirtysmstext),
   //"dirtysmstext" => $this-> dirtysmstext,
   "send" => '',
   "smstext" => $this-> smstext,
   "smsto" => $this-> smsto,
   "smstoprefix" => $this-> smstoprefix,
   "translit" => '',
   "x" => 0,
   "y" => 0,
  );

  $curl_data['post'] = http_build_query($post_data);
  $headers = $ch->set_headers();
  #$headers[] = "Expect: ";
  $curl_data['headers'] =  $headers;
  $curl_data['followlocation'] = true;
  $curl_data['echo_header'] = true;

  $curl_data['referer'] = "https://www.beeline.ru/sms/index.wbp";
  $curl_data['url'] = "https://www.beeline.ru/sms/index.wbp";
  //$curl_data['referer'] = '';
  echo "

\$post_data:

"; print_r($post_data); echo "

\$curl_data:

"; print_r($curl_data); $this->code = $ch->curl($curl_data); $this-> write_string("logs/beeline_send_sms.html", $this->code); //echo $this->code; }
Для работы нужно antigate_API_KEY и captchabot_API_KEY

Комментариев нет:

Отправить комментарий