简体   繁体   English

在我的智能手机上从网络服务器发送消息到移动聊天应用程序(如WhatsApp,Viber或Kik)?

[英]Send message from webserver to mobile chat app (like WhatsApp, Viber or Kik) on my smartphone?

I would like to send notifications from my webserver to my smartphone, preferably through one of the popular mobile chat apps like WhatsApp, Viber or Kik. 我想从我的网络服务器发送通知到我的智能手机,最好通过WhatsApp,Viber或Kik等流行的移动聊天应用程序之一。

Is there any known documentation or API or something, that describes how to send a message to these clients, for example using PHP? 是否有任何已知的文档或API或其他内容,描述如何向这些客户端发送消息,例如使用PHP?

Note that I only need to be able to send notifications to my own smartphone, so requiring specific info to identify my particular client (like cellphone number or something) is fine. 请注意,我只需要能够向我自己的智能手机发送通知,因此需要特定信息来识别我的特定客户端(如手机号码或其他东西)。

There are many web services that allows you to send and receive SMS/notifications. 有许多Web服务允许您发送和接收SMS /通知。 PHP itself doesn't support this on it's own. PHP本身并不支持它。 You can use a service like Twilio to do this. 您可以使用像Twilio这样的服务来执行此操作。 You can send messages to your own smartphone, or even a friend's. 您可以将消息发送到您自己的智能手机,甚至朋友的消息。

An example : 一个例子

<?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";
    }

See the documentation here . 请参阅此处的文档。

Hope this helps! 希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM