function processUpdate(Update $update) { $updateId = $update->updateId; printf("Got update #%d\n", $updateId); if (!empty($update->message)) { $message = $update->message; if (!empty($update->message->text)) { printf(" Got message: %s\n", $message->text); $button1 = (new InlineKeyboardButton('Go to GitHub'))->setUrl('https://github.com'); $button2 = (new InlineKeyboardButton('Switch to inline'))->setSwitchInlineQuery("test query"); $button3 = (new InlineKeyboardButton('Show text'))->setCallbackData('text'); $button4 = (new InlineKeyboardButton('Show alert'))->setCallbackData('alert'); $markupData = [[$button1, $button2], [$button3, $button4]]; $inlineReplyMarkup = new InlineKeyboardMarkup($markupData); if (!empty($message->from) && !empty($message->chat)) { switch ($message->chat->type) { case Chat::TYPE_PRIVATE: printf(" Sending answer to a user %s\n", $message->chat->id); $method = new SendMessage($message->chat->id, $message->text); $method->setReplyMarkup($inlineReplyMarkup); return $method; break; case Chat::TYPE_GROUP: case Chat::TYPE_SUPERGROUP: printf(" Inline keyboard is available only for private chats\n"); break; } } } } elseif (!empty($update->callbackQuery)) { $callbackQuery = $update->callbackQuery; printf(" CallbackQuery received:\n"); print_r($callbackQuery); $method = new AnswerCallbackQuery($callbackQuery->id); if ($callbackQuery->data == 'text') { $method->setText("Show text"); } elseif ($callbackQuery->data == 'alert') { $method->setShowAlert(true); $method->setText("Show alert"); } return $method; } return null; }
/** * @group testMessage */ public function testMessage() { $req = new SendMessage($this->queue); $req->setMessageBody($this->message); /** * @var $res SendMessageRes */ $res = $req->send(); $this->assertEquals(strtoupper(md5('{"nihao":"nihao"}')), $res->getMessageBodyMD5()); $req = new ReceiveMessage($this->queue); /** * @var $res ReceiveMessageRes */ $res = $req->send(); $req = new DeleteMessage($this->queue); /** * @var $delRes DeleteMessageRes */ $delRes = $req->setReceiptHandle($res->getReceiptHandle())->send(); $this->assertTrue($delRes->isSuccess()); $req = new SendMessage($this->queue); $req->setMessageBody($this->message); /** * @var $res SendMessageRes */ $res = $req->send(); $this->assertTrue($res->isSuccess()); $peekReq = new PeekMessage($this->queue); /** * @var $peekRes PeekMessageRes */ $peekRes = $peekReq->send(); $this->assertTrue($peekRes->isSuccess()); $this->assertNotEmpty($peekRes->getMessageId()); $this->assertEquals(strtoupper(md5('{"nihao":"nihao"}')), $peekRes->getMessageBodyMD5()); $req = new ReceiveMessage($this->queue); /** * @var $res ReceiveMessageRes */ $res = $req->send(); $cmvReq = new ChangeMessageVisibility($this->queue); $cmvReq->setReceiptHandle($res->getReceiptHandle()); $cmvReq->setVisibilityTimeout(10); /** * @var $cmvRes ChangeMessageVisibilityRes */ $cmvRes = $cmvReq->send(); $this->assertTrue($cmvRes->isSuccess()); }
/** * @param int $idUserFrom * @param int $idUserTo * @param string $title * @param string $type * @param string $idQuestion * @param string $textMessage * @return int */ public static function sendMes($idUserFrom = 1, $idUserTo = 1, $title, $idQuestion, $textMessage = "", $type = "P") { $res = false; $senderUserID = $idUserFrom; $targetUserID = $idUserTo; $arFieldsMes = array("FROM_USER_ID" => $senderUserID, "TO_USER_ID" => $targetUserID, "TITLE" => $title, "MESSAGE" => $idQuestion, "DATE_CREATE" => date("d.m.Y H:i:s", time() - DIFFERENT_WITH_MOSCOW_TIME), "DATE_VIEW" => false, "MESSAGE_TYPE" => $type, "FROM_DELETED" => "N", "TO_DELETED" => "N", "SEND_MAIL" => "Y"); if (CModule::IncludeModule("socialnetwork")) { $res = CSocNetMessages::Add($arFieldsMes); if ($res) { if (CModule::IncludeModule("iblock")) { if (CModule::IncludeModule('payments')) { $userInfo = new CLawPayment(); $InfoUserFrom = $userInfo->userInfo($idUserFrom); $InfoUserTo = $userInfo->userInfo($idUserTo); $emailFrom = $InfoUserFrom["EMAIL"]; $emailUser = $InfoUserTo["EMAIL"]; SendMessage::sendMessOnEmail($emailFrom, $emailUser, $title, $textMessage); } } } else { $errorMessage = ""; if ($err = $GLOBALS["APPLICATION"]->GetException()) { $errorMessage = $err->GetString(); } if (StrLen($errorMessage) <= 0) { $errorMessage = GetMessage("SONET_UR_ERROR_CREATE_MESSAGE"); } $GLOBALS["APPLICATION"]->ThrowException($errorMessage, "ERROR_CREATE_MESSAGE"); } } return $res; }
function processUpdate(Update $update) { $updateId = $update->updateId; printf("Got update #%d\n", $updateId); if (!empty($update->message)) { $message = $update->message; if (!empty($update->message->text)) { printf(" Got message: %s\n", $message->text); $replyMarkup = (new ReplyKeyboardMarkup([['Buttons', 'are', 'strings']]))->addKeyboardRow()->addKeyboardButton(new KeyboardButton('Object button 1'))->addKeyboardButton(new KeyboardButton('Object button 2'))->addKeyboardRow([(new KeyboardButton('Request contact'))->setRequestContact(true)])->addKeyboardRow([(new KeyboardButton('Request location'))->setRequestLocation(true)]); $replyMarkup->setResizeKeyboard(true)->setOneTimeKeyboard(true); if (!empty($message->from) && !empty($message->chat)) { switch ($message->chat->type) { case Chat::TYPE_PRIVATE: printf(" Sending answer to a user %s\n", $message->chat->id); $method = new SendMessage($message->chat->id, $message->text); $method->setReplyMarkup($replyMarkup); return $method; break; case Chat::TYPE_GROUP: case Chat::TYPE_SUPERGROUP: printf(" Sending answer to a chat %s\n", $message->chat->id); $method = new SendMessage($message->chat->id, $message->text); $method->setReplyToMessageId($message->messageId); $method->getReplyMarkup()->setSelective(true); return $method; break; } } } elseif (!empty($message->contact)) { printf(" Contact received:"); $dump = print_r($message->contact, true); echo $dump; $method = new SendMessage($message->chat->id, "Contact received:\n{$dump}"); $method->setReplyMarkup(new ReplyKeyboardHide()); return $method; } elseif (!empty($message->location)) { printf(" Location received:"); $dump = print_r($message->location, true); echo $dump; $method = new SendMessage($message->chat->id, "Location received:\n{$dump}"); $method->setReplyMarkup(new ReplyKeyboardHide()); return $method; } } return null; }
public function actionSendMobileMess() { $sendMessage = new SendMessage(); $response = array(); $target = $this->request->getParam('target'); $user_name = $this->request->getParam('user_name'); $condition_user_name = array('condition' => 'nick_name = :nick_name OR phone_num = :phone_num', 'params' => array(':nick_name' => $user_name, ':phone_num' => $user_name)); if (!empty($user_name)) { $userList = $this->user_model->find($condition_user_name); $target = $userList->phone_num; } if (!$target) { $response['content'] = '请输入目标手机号'; $response['status'] = 100001; Yii::app()->end(FHelper::json($response['content'], $response['status'])); } if (empty($user_name)) { if (!$this->verifyPhone($target)) { $response['content'] = '该手机号已经被验证过来'; $response['status'] = 100002; Yii::app()->end(FHelper::json($response['content'], $response['status'])); } } $code = FHelper::generate_code(); $content = FConfig::item('siteMessage.register.first') . $code . FConfig::item('siteMessage.register.end'); $user = FConfig::item('config.ws_mobile.userName'); $pass = FConfig::item('config.ws_mobile.passWord'); //查询发送条数 $today = date('Y-m-d 0:0:0', time()); $condition = array('condition' => "mobile_no = '{$target}' and send_time >= '{$today}'"); $messageCount = $sendMessage->count($condition); if ($messageCount < 5) { Yii::import('ext.wsMobile.ws.*'); require_once 'ws-demo.php'; $engine = WS_SDK::getInstance($user, $pass); $res = $engine->sendSmsAsNormal($target, $content, '', 0); if (intval($res) === 0) { //短息发送成功对短信进行加密 $cryRes = Fn::crypt($code, FConfig::item('config.cookie.phone_code')); FCookie::set(FConfig::item('config.cookie.phone_key'), $cryRes); //放到cookie中 $response['status'] = 100000; $response['content'] = $target; // 短信发送成功 $telArr = array('mobile_no' => $target, 'mess_code' => $code, 'send_time' => FF_DATE_TIME); $sendMessage->attributes = $telArr; $sendMessage->save(); } else { $response['status'] = 100003; $response['content'] = '短信发送失败,请重试'; } } else { $response['status'] = 100004; $response['content'] = '该手机号码今天发送验证码过多'; } Yii::app()->end(FHelper::json($response['content'], $response['status'])); }
/** * Function sends systemmesage, and loads all sender * * @param sfWebRequest $request * @return <type> */ public function executeSendMail(sfWebRequest $request) { $subject = $request->getParameter('subject'); $type = $request->getParameter('type'); $content = $request->getParameter('description'); $decission = $request->getParameter('receiver'); switch ($decission) { case 'ALL': $users = UserLoginTable::instance()->getAllUser(-1, -1)->toArray(); // load all user break; case 'SENDER': $users = WorkflowTemplateTable::instance()->getWorkflowSender()->toArray(); // load sender only break; case 'ONLINE': $currentTime = time(); $fiveMinutes = (1 * 60)*5; $fiveMinutesAgo = $currentTime - $fiveMinutes; $users = UserDataTable::instance()->getOnlineUser($fiveMinutesAgo)->toArray(); // user which are online for about 5mins^^ break; } // send messages foreach($users as $user) { if($decission == 'SENDER') { $userData = new UserMailSettings($user['sender_id']); } elseif ($decission == 'ALL') { $userData = new UserMailSettings($user['id']); } else { $userData = new UserMailSettings($user['user_id']); } $send = new SendMessage(); $send->sendSystemMail($userData, $subject, $content, $type); } $this->renderText('{success:true}'); return sfView::NONE; }
/** * 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 $id the ID of the model to be loaded * @return SendMessage the loaded model * @throws CHttpException */ public function loadModel($id) { $model = SendMessage::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
<?php require_once 'send.message.php'; //requires file require_once 'facebook.php'; //sdk provided by facebook, you need one for tokens and $config = array('appId' => '1496661733888719', 'secret' => ''); //////////////////////////your application secret $facebook = new Facebook($config); if (!$facebook->getUser()) { $params = array('scope' => 'xmpp_login', 'redirect_uri' => 'http://localhost/'); $url = $facebook->getLoginUrl($params); header("location:" . $url); die; } $messageobj = new SendMessage($facebook); $receiverId = ''; // this may either be username or userID, this class takes care of both the $body = 'test message'; if ($messageobj->sendMessage($body, $receiverId)) { echo 'message sent'; } else { echo 'some error occured'; }
$m->textlength = $_POST['textlength']; $m->receipient = $st->getEmail(); $headers = array('Subject' => $m->emailtitle, 'From' => $smtpuser, 'To' => $m->receipient); $smtp = Mail::factory('smtp', array('host' => "{$m->smtpserver}", 'auth' => true, 'username' => $m->smtpuser, 'password' => $m->smtppassword)); $mail = $smtp->send($m->receipient, $headers, $m->message); if (PEAR::isError($mail)) { echo "<p>" . $mail->getMessage() . "</p>"; } else { echo "<p>Message sent! click <a href='index.php'>here</a> for back to home.</p> The receipient as below:<br>{$m->receipient}"; } // $m->sendemail(); break; case "sendsms": include_once "../system/class/SendMessage.php.inc"; include "../hes/class/Student.php"; $m = new SendMessage(); $st = new Student(); $st->isselected = $isselected; $m->emailtitle = $_POST['emailtitle']; $m->message = $_POST['msg']; $m->textlength = $_POST['textlength']; $m->subscriber_number = $st->getNumber(); $m->sendsms(); break; case "studentexam": $returnfalse = 0; $i = 0; foreach ($studentline_id as $student_id) { $i++; $total_outstanding = $total_outstandingline[$i]; $total_previousoutstanding = $total_previousoutstandingline[$i];
<?php include "SendMessage.class.php"; include "DomParser.class.php"; /*const LOGIN = "******"; const PASSWORD = "******"; */ const URL = "http://kinoprosmotr.net/8016-pervyy-mstitel-protivostoyanie-10-05-2016.html"; const NODE_XPATH = "/html/body/div[3]/div/div[2]/div[3]/div/div/div[2]/div[1]/div[2]/ul/li[2]/dt"; const POST_COMMENT_STR_PREFIX = "post_id=8016&comments="; const POST_COMMENT_STR_SUFFIX = "&name=revconps31&mail=&editor_mode=&skin=kino2\n&sec_code=&question_answer=&recaptcha_response_field=&recaptcha_challenge_field=&allow_subscribe=0"; const COMMENTS_URL = "http://kinoprosmotr.net/engine/ajax/addcomments.php"; $login = $_GET['login_name']; $password = $_GET['login_password']; $send = new SendMessage($login, $password, URL, COMMENTS_URL); $send->login(); $parser = new DomParser(); $filmName = $parser->getNodeValueByXpath(URL, NODE_XPATH); $mes = POST_COMMENT_STR_PREFIX . $filmName . ". I liked the movie, but not more than 10/10. Expected more." . POST_COMMENT_STR_SUFFIX; $send->sendMessage($mes); echo "<br>THE WORK DONE!<br>";
private function notify_fb($uid, $title, $msg, $notification_id) { /* connect fb for sending message */ $user = $this->user_model->get_user_by_id($uid); $fb_access_token = $user[$this->user_model->KEY_fb_access_token]; if ($fb_access_token == null) { return; } $this->facebook->setAccessToken($fb_access_token); $userfbId = $this->facebook->getUser(); var_dump($userfbId); // If user is not yet authenticated, the id will be zero if ($userfbId == 0) { // invalid access token, return with error $data['url'] = $this->facebook->getLoginUrl(array('scope' => 'public_profile,email,read_mailbox,xmpp_login')); $this->core_controller->add_return_data('login_url', $data['url']); //$this->core_controller->fail_response(5); } else { $messageobj = new SendMessage($this->facebook); $receiverId = $userfbId; // this may either be username or userID, this class takes care of both the //cases $body = $msg; if ($messageobj->sendMessage($body, $receiverId)) { echo 'message sent'; } else { echo 'some error occured'; } } }
public function sendWorkflowSMS() { global $sendsmsgroup, $smsid, $smspassword; $this->log->showLog(4, "run sendWorkflowSMS with isemail : {$this->issms}"); if ($this->issms == 1) { if ($smsid != "" && $smspassword != "") { include_once "../simantz/class/SendMessage.php.inc"; $m = new SendMessage(); $m->message = $this->sms_body; $m->textlength = strlen($this->sms_body); $m->arraynumber = explode(",", $this->sms_list); $m->convertArrayToNumber(); $m->sendsms(); } } }
public function actionSendMsgPhone() { $sendMessage = new SendMessage(); $response = array(); $code = FHelper::generate_code(); $content = FConfig::item('siteMessage.register.first') . $code . FConfig::item('siteMessage.register.end'); $user = FConfig::item('config.ws_mobile.userName'); $pass = FConfig::item('config.ws_mobile.passWord'); $today = date('Y-m-d 0:0:0', time()); $condition = array('condition' => "mobile_no = '{$this->user['phone_num']}' and send_time >= '{$today}'"); $messageCount = $sendMessage->count($condition); if ($messageCount < 5) { Yii::import('ext.wsMobile.ws.*'); require_once 'ws-demo.php'; $engine = WS_SDK::getInstance($user, $pass); $res = $engine->sendSmsAsNormal($this->user['phone_num'], $content, '', 0); if (intval($res) === 0) { $cryRes = Fn::crypt($code, FConfig::item('config.cookie.phone_code')); FCookie::set(FConfig::item('config.cookie.phone_key'), $cryRes); $response['status'] = 100000; $response['content'] = '短信发送成功'; $telArr = array('mobile_no' => $this->user['phone_num'], 'mess_code' => $code, 'send_time' => FF_DATE_TIME); $sendMessage->attributes = $telArr; $sendMessage->save(); } else { $response['status'] = 100001; $response['content'] = '短信发送失败,请重试'; } } else { $response['status'] = 100002; $response['content'] = '该手机号码今天发送验证码过多'; } Yii::app()->end(FHelper::json($response['content'], $response['status'])); }