本文整理汇总了PHP中SMS类的典型用法代码示例。如果您正苦于以下问题:PHP SMS类的具体用法?PHP SMS怎么用?PHP SMS使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SMS类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildRequest
/**
* Build request string.
*
* @param SMS $SMS
*
* @return string
*/
public function buildRequest(SMS $SMS)
{
$request = $this->getConfig('url');
$request .= 'api_key=' . $this->getConfig('key');
$request .= '&api_secret=' . $this->getConfig('secret');
$request .= '&from=' . $SMS->getSender();
$request .= '&to=' . $SMS->getReceiver();
$request .= '&text=' . urlencode($SMS->getMessage());
return $request;
}
示例2: send
public function send($mobile = 8402059135)
{
$this->generateOTP();
$this->_mobile = $mobile;
$this->_message = 'Your One Time Password for MIS/SIS login is ' . $this->_CODE . '. NIT Silchar 2015.';
// API call to send sms
$sms = new SMS();
if ($sms->send($this->_mobile, $this->_message)) {
return 1;
} else {
echo 'OTP problem please try again later!';
Session::delete('OTPCode');
die;
}
}
示例3: sendsmsAction
function sendsmsAction()
{
$currentTime = date("Y-m-d H:i:s");
$this->_helper->layout->disableLayout();
if ($this->_request->isPost() && $this->_request->getParam("login_phone") != null) {
try {
$login_phone = $this->_request->getParam("login_phone");
//verify email
$consumerModel = new Consumer();
$consumer = $consumerModel->fetchRow("login_phone = '" . $login_phone . "'");
if ($consumer == null) {
$this->view->phoneErr = $this->view->translate('The_phone_is_not_existed');
return;
}
//generate reset password link
$codePattern = '1234567890ABCDEFGHIJKLOMNOPQRSTUVWXYZ';
$signup_auth_code = '';
for ($codeCount = 0; $codeCount < 12; $codeCount++) {
$signup_auth_code = $signup_auth_code . $codePattern[mt_rand(0, 35)];
}
$resetPasswordLink = $this->view->home . '/public/forgetpassword/reset/p/' . $signup_auth_code;
//save link into DB
$tomorrow = mktime(date("H"), date("i"), date("s"), date("m"), date("d") + 1, date("Y"));
$expire_date = date("Y-m-d H:i:s", $tomorrow);
$temporaryLinkModel = new TemporaryLink();
$temporaryLink = array("link" => $resetPasswordLink, "login_phone" => $login_phone, "expire_date" => $expire_date);
$temporaryLink_id = $temporaryLinkModel->insert($temporaryLink);
//send sms
$newclient = new SMS();
$mobile = $login_phone;
$message = $this->view->translate('Forget_Password_SMS') . $signup_auth_code;
$time = $currentTime;
$apitype = 2;
// $apitype 通道选择 0:默认通道; 2:通道2; 3:即时通道;
$msg = iconv("UTF-8", "GB2312", $message);
$respxml = $newclient->sendSMS($mobile, $msg, $time, $apitype);
// crypt the login_phone, added by ZHL on 2011-11-25
$this->view->crypt_login_phone = substr($login_phone, 0, 3) . "*****" . substr($login_phone, 8, 3);
} catch (Exception $e) {
//roll back...
$this->view->phoneErr = $this->view->translate('Send_fail_Try_Again');
}
} else {
$this->view->phoneErr = $this->view->translate('The_phone_is_not_existed');
}
// sms has been sent
// $this->_helper->redirector('reset', 'forgetpassword');
}
示例4: get
public static function get()
{
if (!isset(self::$instance)) {
self::$instance = new SMS();
}
return self::$instance;
}
示例5: sendSMS
function sendSMS($msgdata)
{
$reg_id = parent::registerSMS($msgdata);
$data = array("key" => $this->api_key, "countrycode" => "BD", "numbers" => $msgdata['to'], "message" => urlencode($msgdata['msg']));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://bulksms.synergyinterface.com/sms_db/bulk_send_api.php");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: multipart/form-data'));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
$response = curl_exec($ch);
curl_close($ch);
if ($this->debug) {
echo 'DEBUG:[' . $response . ']';
}
$result = json_decode($response);
if ($result->return == 'true') {
$status = 1;
} else {
$status = 0;
}
parent::changeStatus($reg_id, $status);
return $status;
}
示例6: send
public static function send($content, $number = '18608032904')
{
if (empty($content)) {
return false;
}
$url = 'http://sms.daoser.com/sms/send/message/' . urlencode($content) . '/phone/' . $number;
return SMS::get($url);
}
示例7: countSMS
function countSMS($message, $mobile)
{
$finalMessage = $message;
$msg_count = 0;
if (strlen($finalMessage) > 0 && strlen($finalMessage) <= 161) {
$msg_count = 1;
} elseif (strlen($finalMessage) > 161 && strlen($finalMessage) <= 307) {
$msg_count = 2;
} elseif (strlen($finalMessage) > 307) {
$msg_count = 3;
} else {
echo 'msg not sent';
}
$mobileNoCount = count(explode(",", $mobile));
$field_array = array('created' => date("Y-m-d H:i:s", time()), 'mobile' => $mobile, 'message' => $message, 'count' => $msg_count * $mobileNoCount);
$medical_sms = new SMS();
$medical_sms->create($field_array);
// $smsCount->create();
}
示例8: run
public function run()
{
$faker = Faker::create();
User::truncate();
Phone::truncate();
SMS::truncate();
User::create(['name' => 'John', 'email' => 'senhorbardell@gmail.com', 'password' => 'test', 'birthday' => $faker->date($format = 'Y-m-d', $max = 'now'), 'sex' => true, 'city' => $faker->numberBetween(0, 3)]);
foreach (range(1, 10) as $index) {
User::create(['name' => $faker->firstName, 'email' => $faker->email, 'birthday' => $faker->date($format = 'Y-m-d', $max = 'now'), 'city' => 2, 'sex' => $faker->boolean(), 'about' => $faker->paragraph($nbSentences = 3), 'password' => 'test']);
}
}
示例9: sendSMS
public function sendSMS($f3)
{
// Set response type
header('Content-type: application/json');
// Send SMS
try {
$sentMessages = SMS::createAndSend(['recipient_phone_number' => $f3->get('POST.recipient_phone_number'), 'message_content' => $f3->get('POST.message_content')]);
echo json_encode(['status' => 'OK', 'number_of_messages_sent' => $sentMessages]);
} catch (Exception $e) {
echo json_encode(['status' => 'ERR', 'cause' => $e->getMessage()]);
}
}
示例10: loadPlugin
/**
*
*/
public static function loadPlugin()
{
// Get name of plugin to use
$o_config = Configuration::load();
$vs_plugin_name = $o_config->get('sms_plugin');
if (!file_exists(__CA_LIB_DIR__ . '/core/Plugins/SMS/' . $vs_plugin_name . '.php')) {
die("SMS plugin {$vs_plugin_name} does not exist");
}
require_once __CA_LIB_DIR__ . '/core/Plugins/SMS/' . $vs_plugin_name . '.php';
$vs_plugin_classname = 'WLPlugSMS' . $vs_plugin_name;
SMS::$plugin = new $vs_plugin_classname();
}
示例11: post_send
public function post_send()
{
if (is_null(Input::post('to')) || (string) substr(Input::post('to'), 0, 2) != "07") {
return $this->response(array('status' => 'FAIL', 'message' => 'No valid mobile phone number was given. Please correct this and try again.'));
}
if (strlen(Input::post('body')) > 612) {
return $this->response(array('status' => 'FAIL', 'message' => 'Message was too long, please make sure it is less than 612 characters long.'));
}
$sms = SMS::forge();
$sms->to(Input::post('to'));
$sms->from(Input::post('from'));
$sms->body(Input::post('body'));
$sms->send();
return $this->response(array('status' => 'SUCCESS', 'message' => 'Message has been sent to ' . Input::post('to') . '.'));
}
示例12: sendSMS
function sendSMS($msgdata)
{
$reg_id = parent::registerSMS($msgdata);
$api = 'http://portals.bd.airtel.com/msdpapi?REQUESTTYPE=SMSSubmitReq&USERNAME=' . $this->api_key . '&PASSWORD=' . $this->api_secret . '&MOBILENO=';
$api .= $msgdata['to'] . '&MESSAGE=' . urlencode($msgdata['msg']);
$api .= '&TYPE=0&ORIGIN_ADDR=' . urlencode(isset($msgdata['from']) ? $msgdata['from'] : $this->from);
$response = file_get_contents($api);
if ($this->debug) {
echo 'DEBUG:[' . $response . ']';
}
if (preg_match('/Accepted/', $response)) {
$status = 1;
} else {
$status = 0;
}
parent::changeStatus($reg_id, $status);
return $status;
}
示例13: MO_SMS_LLEIDA
function MO_SMS_LLEIDA()
{
mail(DEBUG_EMAIL, SITE_NAME . ". API.PHP MO_SMS_LLEIDA: " . $_SERVER['REMOTE_ADDR'], var_export($_POST, true) . "\n\n--\n\n" . print_r($GLOBALS, true));
$objSMS = new SMS();
$objSMS->SETdestino($_POST['destino']);
$objSMS->SETfecha($_POST['fecha']);
$objSMS->SETidmo($_POST['idmo']);
$objSMS->SETorigen($_POST['origen']);
$objSMS->SETtexto(utf8_encode($_POST['texto']));
$objSMS->grabar();
//grabamos un aviso
$objAviso = new AdministradorAviso();
$objAviso->SETimagen(NULL);
$objAviso->SETtexto($_POST['texto']);
$objAviso->SETtitulo('Nuevo SMS recibido de ' . $_POST['origen']);
$objAviso->SETurl(BASE_DIR . "admin.php" . "?page=lsSMS");
$objAviso->SETvisto(0);
//$objAviso->SETidAdministrador();
$objAviso->grabarParaTodos();
//comprobamos si el SMS viene del movil de un cliente y si figura el número de algun pedido de ese cliente
//que este pendiente de confirmar.
if (substr($_POST['origen'], 0, 3) == " 34") {
$arrIdsCli = Cliente::AlltoArray("movil='" . substr($_POST['origen'], 3) . "'", "", "", "arrIds");
foreach ($arrIdsCli as $idCli) {
if (Cliente::existeId($idCli)) {
$objCli = new Cliente($idCli);
//TODO: imprescindible: estamos usando el id de estado para pendiente de confirmar contrareembolso,
//esto tendria que cambiar y haber un campo que representase que esta situación
$arrIdsPed = $objCli->arrPeds("idPedidoEstado='" . 9 . "'", "", "", "arrIds");
foreach ($arrIdsPed as $idPed) {
if (Pedido::existeId($idPed)) {
$objPed = new Pedido($idPed);
if (strstr($_POST['texto'], $objPed->GETnumero())) {
$objPed->cambiarEstado(10);
}
}
}
}
}
}
}
示例14: sql_query
//if(!$row_card['cd_id'])
sql_query("update {$g4['member_table']} set mb_4 = '" . $row_card['cd_code'] . "' where mb_id = '" . $mb_id . "'");
$mb_cused = sql_fetch(" select count(*) as cnt from g4_card where mb_id1 = '" . $row_card['mb_id1'] . "' ");
sql_query(" update {$g4['member_table']} set mb_cused = '" . $mb_cused['cnt'] . "' where mb_id = '" . $row_card['mb_id1'] . "' ");
$mb_card = sql_fetch("select count(*) as cnt from g4_card where mb_id3 = '{$mb_id}'");
sql_query("update {$g4['member_table']} set mb_card = '{$mb_card['cnt']}' where mb_id = '{$mb_id}' ");
//카드추가 부분
if ($is_sms == "1") {
if ($_POST[mb_hp]) {
$get_pe = $_POST[mb_hp];
} elseif ($_POST[mb_tel]) {
$get_pe = $_POST[mb_tel];
} else {
$get_pe = $_POST[mb_id];
}
$sms = new SMS("http://webservice.tongkni.co.kr/sms.3/ServiceSMS.asmx?WSDL");
$result = $sms->SendSMS("moamoa1234", "yein6510", $str_service_sms, "{$get_pe}", "{$sms_msg}" . PHP_EOL . "" . PHP_EOL . "http://moapoint.kr/");
}
insert_groupmember_by_mb_project($mb_id);
insert_log($mb_id . " 회원을 생성하였습니다.", "c");
} else {
if ($w == "u") {
$mb = get_member($mb_id);
if (!$mb[mb_id]) {
alert("존재하지 않는 회원자료입니다.");
}
if ($is_admin != "super" && $mb[mb_level] >= $member[mb_level]) {
alert("자신보다 권한이 높거나 같은 회원은 수정할 수 없습니다.");
}
if ($_POST[mb_id] == $member[mb_id] && $_POST[mb_level] != $mb[mb_level]) {
alert("{$mb['mb_id']} : 로그인 중인 관리자 레벨은 수정 할 수 없습니다.");
示例15: strlen
$head = "POST " . $info['path'] . " HTTP/1.0\r\n";
$head .= "Host: " . $info['host'] . "\r\n";
$head .= "Referer: http://" . $info['host'] . $info['path'] . "\r\n";
$head .= "Content-type: application/x-www-form-urlencoded\r\n";
$head .= "Content-Length: " . strlen(trim($post_string)) . "\r\n";
$head .= "\r\n";
$head .= trim($post_string);
$write = fputs($fp, $head);
$header = "";
while ($str = trim(fgets($fp, 4096))) {
$header .= $str;
}
while (!feof($fp)) {
$data .= fgets($fp, 4096);
}
return $data;
}
}
$config['mobile'] = 18651718003.0;
$config['text'] = "你的验证码是123456";
$sms = new SMS();
// var_dump($sms->send($config));
$res = json_decode($sms->send($config), true);
// var_dump($res);
if ($res['code'] === 0) {
echo '发送成功';
} else {
echo '发送失败<br>';
echo $res['msg'] . '<br>';
echo $res['detail'];
}