本文整理汇总了PHP中Message::setText方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setText方法的具体用法?PHP Message::setText怎么用?PHP Message::setText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Message
的用法示例。
在下文中一共展示了Message::setText方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testCreate
/**
* Tests for success at creating the object.
*/
public function testCreate()
{
$test_text = 'test text';
$t = new Message();
$t->setText($test_text);
$this->assertTrue($t instanceof Message);
$this->assertEquals($t->__toString(), $test_text);
}
示例2: send
/**
* Send an email using a Transactional email service
* or native PHP as a fallback.
*
* @param array $attributes A list of attributes for sending
* @return bool on success
*/
public static function send($attributes = array())
{
/*
|--------------------------------------------------------------------------
| Required attributes
|--------------------------------------------------------------------------
|
| We first need to ensure we have the minimum fields necessary to send
| an email.
|
*/
$required = array_intersect_key($attributes, array_flip(self::$required));
if (count($required) >= 3) {
/*
|--------------------------------------------------------------------------
| Load handler from config
|--------------------------------------------------------------------------
|
| We check the passed data for a mailer + key first, and then fall back
| to the global Statamic config.
|
*/
$email_handler = array_get($attributes, 'email_handler', Config::get('email_handler', null));
$email_handler_key = array_get($attributes, 'email_handler_key', Config::get('email_handler_key', null));
if (in_array($email_handler, self::$email_handlers) && $email_handler_key) {
/*
|--------------------------------------------------------------------------
| Initialize Stampie
|--------------------------------------------------------------------------
|
| Stampie provides numerous adapters for popular email handlers, such as
| Mandrill, Postmark, and SendGrid. Each is written as an abstract
| interface in an Adapter Pattern.
|
*/
$mailer = self::initializeEmailHandler($email_handler, $email_handler_key);
/*
|--------------------------------------------------------------------------
| Initialize Message class
|--------------------------------------------------------------------------
|
| The message class is an implementation of the Stampie MessageInterface
|
*/
$email = new Message($attributes['to']);
/*
|--------------------------------------------------------------------------
| Set email attributes
|--------------------------------------------------------------------------
|
| I hardly think this requires much explanation.
|
*/
$email->setFrom($attributes['from']);
$email->setSubject($attributes['subject']);
if (isset($attributes['text'])) {
$email->setText($attributes['text']);
}
if (isset($attributes['html'])) {
$email->setHtml($attributes['html']);
}
if (isset($attributes['cc'])) {
$email->setCc($attributes['cc']);
}
if (isset($attributes['bcc'])) {
$email->setBcc($attributes['bcc']);
}
if (isset($attributes['headers'])) {
$email->setHeaders($attributes['headers']);
}
$mailer->send($email);
return true;
} else {
/*
|--------------------------------------------------------------------------
| Native PHP Mail
|--------------------------------------------------------------------------
//.........这里部分代码省略.........
示例3: send
/**
* Send an email using a Transactional email service
* or native PHP as a fallback.
*
* @param array $attributes A list of attributes for sending
* @return bool on success
*/
public static function send($attributes = array())
{
/*
|--------------------------------------------------------------------------
| Required attributes
|--------------------------------------------------------------------------
|
| We first need to ensure we have the minimum fields necessary to send
| an email.
|
*/
$required = array_intersect_key($attributes, array_flip(self::$required));
if (count($required) >= 3) {
/*
|--------------------------------------------------------------------------
| Load handler from config
|--------------------------------------------------------------------------
|
| We check the passed data for a mailer + key first, and then fall back
| to the global Statamic config.
|
*/
$email_handler = array_get($attributes, 'email_handler', Config::get('email_handler', null));
$email_handler_key = array_get($attributes, 'email_handler_key', Config::get('email_handler_key', null));
if (in_array($email_handler, self::$email_handlers) && $email_handler_key) {
/*
|--------------------------------------------------------------------------
| Initialize Stampie
|--------------------------------------------------------------------------
|
| Stampie provides numerous adapters for popular email handlers, such as
| Mandrill, Postmark, and SendGrid. Each is written as an abstract
| interface in an Adapter Pattern.
|
*/
$mailer = self::initializeEmailHandler($email_handler, $email_handler_key);
/*
|--------------------------------------------------------------------------
| Initialize Message class
|--------------------------------------------------------------------------
|
| The message class is an implementation of the Stampie MessageInterface
|
*/
$email = new Message($attributes['to']);
/*
|--------------------------------------------------------------------------
| Set email attributes
|--------------------------------------------------------------------------
|
| I hardly think this requires much explanation.
|
*/
$email->setFrom($attributes['from']);
$email->setSubject($attributes['subject']);
if (isset($attributes['text'])) {
$email->setText($attributes['text']);
}
if (isset($attributes['html'])) {
$email->setHtml($attributes['html']);
}
if (isset($attributes['cc'])) {
$email->setCc($attributes['cc']);
}
if (isset($attributes['bcc'])) {
$email->setBcc($attributes['bcc']);
}
if (isset($attributes['headers'])) {
$email->setHeaders($attributes['headers']);
}
$mailer->send($email);
return true;
} else {
/*
|--------------------------------------------------------------------------
| Native PHP Mail
|--------------------------------------------------------------------------
|
| We're utilizing the popular PHPMailer class to handle the messy
| email headers and do-dads. Emailing from PHP in general isn't the best
| idea known to man, so this is really a lackluster fallback.
|
*/
$email = new PHPMailer(true);
$email->IsMAIL();
$email->CharSet = 'UTF-8';
$email->AddAddress($attributes['to']);
$email->From = $attributes['from'];
$email->FromName = $attributes['from'];
$email->Subject = $attributes['subject'];
if (isset($attributes['text'])) {
$email->AltBody = $attributes['text'];
}
//.........这里部分代码省略.........
示例4: message_submit
function message_submit()
{
// get global user object
global $user;
// protect from unauthorized access
if (!isset($user) || !isset($_POST['formMessageSubmit']) || !isset($_POST['formMessage'])) {
logout();
die;
}
// get message data from $_POST
$title = filter_input(INPUT_POST, 'messageTitle');
$text = filter_input(INPUT_POST, 'messageText');
$time_now = date("Y-m-d H:i:s");
// send mail
send_mail($title, $text);
// set message object
$message = new Message();
$message->setIsActive(1);
$message->setCreatedOn($time_now);
$message->setLastEditedOn($time_now);
$message->setUser($user->getId());
$message->setTitle($title);
$message->setText($text);
// store message object in db
$message->store_in_db();
// set message cookie
$cookie_key = 'msg';
$cookie_value = 'Благодарим Ви за съобщението!';
setcookie($cookie_key, $cookie_value, time() + 1);
header('location:' . ROOT_DIR . '?page=survey_role');
}
示例5: header
$Statement = $Database->prepare("UPDATE users SET thumbnail = ? WHERE id = ?");
$Statement->execute(array($thumbnailUrl, $user["id"]));
header("Location: " . $_SERVER["REQUEST_URI"]);
} catch (Exception $e) {
echo $e->getMessage();
}
}
}
}
//Process the message reply form
if (isset($_POST["send_reply" . $messageCount])) {
$Message = new Message($user["id"], $Database);
//Instantiate the message class
try {
$Message->setReciever($_POST["sid" . $messageCount]);
$Message->setText($_POST["message_text" . $messageCount]);
$Message->send();
} catch (Exception $e) {
echo $e->getMessage();
}
header("Location: " . $_SERVER["REQUEST_URI"]);
}
#####################################################
/**
* Displays the html of the page based on the page settings
*/
if (!empty($user)) {
//If the user is logged in
require $baseDir . 'includes/templates/page_header.php';
} else {
//If the user isn't logged in
示例6: Message
<?php
session_start();
require_once '../resources/require.php';
// dodoaje nową wiadomość do bazy, uzupełnia komunikat o wysłaniu bądź błędzie
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['verify_post'])) {
if (trim($_POST['message_text']) != '') {
$message = new Message($mysqli);
$message->setReceiverId($_POST['receiver_id']);
$message->setSenderId($_SESSION['user_id']);
$message->setText($_POST['message_text']);
$message->setStatus(0);
$message->setCreationDate(date("Y-m-d H:i:s"));
if (!$message->create()) {
$info = 'Nie udało się wysłać wiadomości. Spróbuj ponownie.';
} else {
$info = 'Wiadomość została wysłana.';
}
} else {
$info = 'Uzupełnij treść wiadomości.';
}
}
?>
<!DOCTYPE html>
<html lang="pl-PL">
<title>Twitter | Wyślij wiadomość </title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"
示例7: setText
/**
* Set text part of the message.
*
* @param string $text
* @return Mail
*/
public function setText($text)
{
$this->message->setText($text);
return $this;
}
示例8: inbox
public function inbox($delete = true)
{
$dataArray = $this->getAuthData();
$dataArray['action'] = 'inbox';
$response = new \SimpleXMLElement($this->getAnswer((string) $this->httpClient->get($this->apiScript, ['query' => array_merge($dataArray, ['delete' => $delete ? 1 : 0])])->getBody()));
if ((int) $response->err > 0) {
throw new IOException('Sending error ' . (int) $response->err . ': ' . $this->getErrorMessage((int) $response->err), (int) $response->err);
}
$list = [];
foreach ($response->inbox->delivery_sms as $it) {
if (empty($it)) {
continue;
}
$message = new Message();
$message->setNumber((string) $it->number);
$message->setText((string) $it->message);
$message->setDate(\DateTime::createFromFormat('Ymd His', str_replace('T', ' ', $it->time)));
$list[] = $message;
}
return $list;
}
示例9: parseMessage
public function parseMessage($messageObject)
{
$message = new Message();
$message->setMessageId($messageObject->message_id);
$message->setFrom($this->parseUser($messageObject->from));
$message->setDate($messageObject->date);
// TODO: test it for User and GroupChat types
$message->setChat($this->parseChat($messageObject->chat));
if (property_exists($messageObject, 'forward_from')) {
$message->setForwardFrom($this->parseUser($messageObject->forward_from));
}
if (property_exists($messageObject, 'forward_date')) {
$message->setForwardDate($messageObject->forward_date);
}
// TODO: reply to message attribute
if (property_exists($messageObject, 'text')) {
$message->setText($messageObject->text);
}
if (property_exists($messageObject, 'audio')) {
$message->setAudio($this->parseAudio($messageObject->audio));
}
if (property_exists($messageObject, 'document')) {
$message->setDocument($this->parseDocument($messageObject->document));
}
if (property_exists($messageObject, 'photo')) {
$message->setPhoto($this->parsePhotoSize($messageObject->photo));
}
if (property_exists($messageObject, 'sticker')) {
$message->setSticker($this->parseSticker($messageObject->sticker));
}
if (property_exists($messageObject, 'video')) {
$message->setVideo($this->parseVideo($messageObject->video));
}
if (property_exists($messageObject, 'voice')) {
$message->setVoice($this->parseVoice($messageObject->voice));
}
if (property_exists($messageObject, 'caption')) {
$message->setCaption($messageObject->caption);
}
if (property_exists($messageObject, 'contact')) {
$message->setContact($this->parseContact($messageObject->contact));
}
if (property_exists($messageObject, 'location')) {
$message->setLocation($this->parseLocation($messageObject->location));
}
if (property_exists($messageObject, 'new_chat_participant')) {
$message->setNewChatParticipant($this->parseUser($messageObject->new_chat_participant));
}
if (property_exists($messageObject, 'left_chat_participant')) {
$message->setLeftChatParticipant($this->parseUser($messageObject->left_chat_participant));
}
if (property_exists($messageObject, 'new_chat_title')) {
$message->setNewChatTitle($messageObject->new_chat_title);
}
if (property_exists($messageObject, 'new_chat_photo')) {
$message->setNewChatPhoto($this->parsePhotoSize($messageObject->new_chat_photo));
}
// TODO: not sure about implementation of TRUE type
if (property_exists($messageObject, 'delete_chat_photo')) {
$message->setDeleteChatPhoto($messageObject->delete_chat_photo);
}
if (property_exists($messageObject, 'group_chat_created')) {
$message->setGroupChatCreated($messageObject->group_chat_created);
}
return $message;
}
示例10: loadAllSent
public function loadAllSent()
{
$conn = $this->connection;
$arrayWithMessages = [];
$sqlQuery = "SELECT id, text, receiver_id, created_at FROM messages WHERE sender_id = {$this->id} ORDER BY messages.created_at DESC";
$result = $conn->query($sqlQuery);
if ($result->num_rows > 0) {
while (list($id, $text, $receiverId, $createdAt) = $result->fetch_array(MYSQLI_NUM)) {
$message = new Message($conn);
$message->setId($id);
$message->setText($text);
$message->setSenderId($this->id);
$message->setReceiverId($receiverId);
$message->setCreatedAt($createdAt);
$arrayWithMessages[] = $message;
}
return $arrayWithMessages;
}
return false;
}
示例11: Message
include_once "configRoot.php";
require_once ROOT_NAME . "/includes/authToken.php";
require_once ROOT_NAME . "/includes/checkProfile.php";
require_once ROOT_NAME . "/classes/Database.php";
require_once ROOT_NAME . "/classes/Message.php";
$receiverId = $_GET["receiver_id"];
$receiverNick = $_GET["receiver_nick"];
$senderId = $id;
// id from a cookie
if (isset($_POST["message"])) {
$text = $_POST["message"];
$db = Database::getInstance();
$conn = $db->getConnection();
$message = new Message($conn);
$message->setText($text);
$message->setReceiverId($receiverId);
$message->setSenderId($senderId);
$result = $message->addToDatabase();
if ($result) {
echo "<h2>Message sent!</h2>";
} else {
echo "<p>Error</p>";
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">