我想将通知从我的网络服务器发送到我的智能手机,最好是通过 WhatsApp、Viber 或 Kik 等流行的移动聊天应用程序之一。
是否有任何已知的文档或 API 或其他东西,描述如何向这些客户端发送消息,例如使用 PHP?
请注意,我只需要能够向我自己的智能手机发送通知,因此需要特定信息来识别我的特定客户(如手机号码或其他东西)就可以了。
有许多网络服务允许您发送和接收短信/通知。PHP 本身并不支持这一点。您可以使用 Twilio 之类的服务来执行此操作。您可以将消息发送到自己的智能手机,甚至是朋友的智能手机。
一个例子:
<?php
require "Services/Twilio.php";
// Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
$AccountSid = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX";
$AuthToken = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY";
// Step 3: instantiate a new Twilio Rest Client
$client = new Services_Twilio($AccountSid, $AuthToken);
// Step 4: make an array of people we know, to send them a message.
// Feel free to change/add your own phone number and name here.
$people = array(
"+14158675309" => "Curious George",
"+14158675310" => "Boots",
"+14158675311" => "Virgil",
);
// Step 5: Loop over all our friends. $number is a phone number above, and
// $name is the name next to it
foreach ($people as $number => $name) {
$sms = $client->account->sms_messages->create(
// Step 6: Change the 'From' number below to be a valid Twilio number
// that you've purchased, or the (deprecated) Sandbox number
"YYY-YYY-YYYY",
// the number we are sending to - Any phone number
$number,
// the sms body
"Hey $name, Monkey Party at 6PM. Bring Bananas!"
);
// Display a confirmation message on the screen
echo "Sent message to $name";
}
请参阅此处的文档。
希望这可以帮助!