我想通过我的网络服务器向我的智能手机发送通知,最好是通过WhatsApp,Viber或Kik等流行的移动聊天应用程序之一。
是否有任何已知的文档或API或其他内容,描述如何向这些客户端发送消息,例如使用PHP?
请注意,我只需要能够向我自己的智能手机发送通知,因此需要特定信息来识别我的特定客户端(如手机号码等)。
答案 0 :(得分:4)
有许多网络服务允许您发送和接收短信/通知。 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";
}
请参阅文档here。
希望这有帮助!