本文整理汇总了PHP中Sms::model方法的典型用法代码示例。如果您正苦于以下问题:PHP Sms::model方法的具体用法?PHP Sms::model怎么用?PHP Sms::model使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sms
的用法示例。
在下文中一共展示了Sms::model方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
public static function handle($task)
{
echo '<pre>';
echo date('Y-m-d H:i:s') . ' handle task: ' . $task;
echo "\r\n";
switch ($task) {
case 'sms':
Sms::model()->send();
break;
}
}
示例2: actionRegister
/**
* 新用户注册
*
*/
public function actionRegister()
{
$this->layout = " ";
Yii::app()->clientScript->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jquery-1.9.1.js');
Yii::app()->clientScript->registerCssFile(Yii::app()->theme->baseUrl . '/css/login.css');
$username = Yii::app()->request->getQuery('username', null);
$phone = Yii::app()->request->getQuery('phone', null);
$email = Yii::app()->request->getQuery('email', null);
$model = new User('create');
if (isset($_POST['User'])) {
$model->attributes = $_POST['User'];
if ($model->validate()) {
$code_model = Temp::model()->findByPk(trim($model->phone));
if (!empty($code_model)) {
if (time() - $code_model->time <= 180) {
if ($model->sms_code == $code_model->code) {
if ($model->save()) {
$userInfo = new UserInfo();
$userInfo->userId = $model->id;
$userInfo->username = $model->username;
$userInfo->phone = $model->phone;
$userInfo->save();
$this->redirect(array('registerSuccess'));
}
} else {
$model->addError('sms_code', '验证码不正确');
}
} else {
$model->addError('sms_code', '验证码已失效,请重新获取');
}
} else {
$model->addError('sms_code', '验证失败,请重新获取');
}
}
}
if (!empty($username) && trim($username) != '您的姓名') {
$model->username = $username;
}
if (!empty($phone) && trim($phone) != '您的电话') {
$model->phone = $phone;
}
if (!empty($email) && trim($email) != '您的邮箱') {
$model->email = $email;
}
$sms_list = Sms::model()->findAll();
$link_list = Link::model()->findAll();
$this->render('create', array('model' => $model, 'sms_data' => $sms_list[0], 'link_list' => $link_list));
}
示例3: actionReplyMessage
public function actionReplyMessage()
{
if (isset(Yii::app()->params['twilio']['replyMessage']) && Yii::app()->params['twilio']['replyMessage']) {
file_put_contents(Yii::app()->params['logDirPath'] . '/twilio_request.log', print_r($_REQUEST, true) . "\n\n", FILE_APPEND);
$phone = str_replace('+44', '', $_REQUEST['From']);
$client = Client::model()->findByPhone($phone);
$sms = new Sms();
$sms->clientId = $client ? $client->cli_id : 0;
$sms->receive($_REQUEST);
if ($client) {
$latestText = Sms::model()->latestTextToClient($client);
}
header('content-type: text/xml');
echo '<Response><Sms><![CDATA[' . Yii::app()->params['twilio']['replyMessage'] . ']]></Sms></Response>';
}
}
示例4: loadModel
/**
* Returns the data model based on the primary key given in the GET variable.
* If the data model is not found, an HTTP exception will be raised.
* @param integer the ID of the model to be loaded
*/
public function loadModel($id)
{
$model = Sms::model()->findByPk($id);
if ($model === null) {
throw new CHttpException(404, 'The requested page does not exist.');
}
return $model;
}
示例5: send
public function send()
{
$criteria = new CDbCriteria();
$criteria->addCondition('status = 0 AND stime <=' . time());
$criteria->order = 'id ASC';
$sms = Sms::model()->findAll($criteria);
if (!empty($sms)) {
foreach ($sms as $s) {
$numbers = array();
if ($s->send_all == 1) {
$criteria = new CDbCriteria();
$criteria->addCondition('id != 0 AND resignation = 0 AND disabled = 0 AND is_deleted =0');
$users = User::model()->findAll($criteria);
if (!empty($users)) {
foreach ($users as $u) {
$numbers[] = $u->phone;
}
}
} else {
$users = $s->to_user();
if (!empty($users)) {
foreach ($users as $u) {
$numbers[] = $u->user->phone;
}
}
}
if (!empty($numbers)) {
try {
if (ISMG::send($s->message, implode(',', $numbers))) {
$s->status = 1;
$s->save();
} else {
throw new Exception('Send SMS Error');
}
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
}
return true;
}
示例6: actionTextConversation
public function actionTextConversation($clientId)
{
$this->layout = '//layouts/fixed';
$highlightText = null;
if (isset($_GET['messageId']) && $_GET['messageId']) {
$highlightText = Sms::model()->findByPk($_GET['messageId']);
if (!$highlightText) {
throw new CHttpException(404, 'message [id:' . $_GET['messageId'] . '] not found');
}
if (!$highlightText->isRead()) {
$highlightText->markRead(Yii::app()->user->id);
}
}
$client = Client::model()->findByPk($clientId);
if (!$client) {
throw new CHttpException(404, 'client [id : ' . $clientId . '] is not found');
}
$this->render('textConversation', array('client' => $client, 'highlightText' => $highlightText));
}
示例7: loadModel
/**
* @param $id
* @return Sms
* @throws CHttpException
*/
public function loadModel($id)
{
$model = Sms::model()->findByPk($id);
if (!$model) {
throw new CHttpException(404, "message [id: " . $id . "] is not found");
}
return $model;
}