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