【问题标题】:Whatsapp API - send a notification message to another phone numberWhatsapp API - 向另一个电话号码发送通知消息
【发布时间】:2022-04-07 01:28:07
【问题描述】:

我正在寻找一种使用 Whatsapp API 直接向客户电话号码发送通知的方法

我在一个网站上找到一篇文章,详细解释了如何激活和使用 Whatsapp API。

Add the phone number +34 644 76 66 43 into your Phone Contacts. (Name it it as you wish)

Send this message "I allow callmebot to send me messages" to the new Contact created (using WhatsApp of course)

Wait until you receive the message "API Activated for your phone number. Your APIKEY is 123123" from the bot.

Note: If you don't receive the ApiKey in 2 minutes, please try again after 24hs.

The WhatsApp message from the bot will contain the apikey needed to send messages using the API.

You can send text messages using the API after receiving the confirmation.

完美收据apikey

如何使用 CURL 库从 PHP 发送 WhatsApp 消息 使用 cURL 库从 PHP 发送 WhatsApp 消息非常简单。我建议您创建一个函数,然后在每次要发送消息时调用该函数。

首先,在您的 php 代码中创建函数“send_whatsapp”,如下所示:

function send_whatsapp($message="Test"){
    $phone="NUMBER";  // Enter your phone number here
    $apikey="YOUR_API_KEY";       // Enter your personal apikey received in step 3 above

    $url='https://api.callmebot.com/whatsapp.php?source=php&phone='.$phone.'&text='.urlencode($message).'&apikey='.$apikey;

    if($ch = curl_init($url))
    {
        curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);
        $html = curl_exec($ch);
        $status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        // echo "Output:".$html;  // you can print the output for troubleshooting
        curl_close($ch);
        return (int) $status;
    }
    else
    {
        return false;
    }
}

只需将$phone$apikey 变量更新为您在上述第3 步中获得的变量即可。

然后从代码中的任何位置调用该函数。

send_whatsapp("this is a test from PHP");    //Text message that your would like to send

您可以从代码中的不同位置调用 send_whatsapp 函数。

问题

完美,每次都会向我指定的号码发送一条消息以激活通知系统。

但是如果我不想将它发送到我的号码而是发送到客户号码呢?

【问题讨论】:

    标签: php whatsapp whatsapi


    【解决方案1】:

    只是在这里提出一个建议。实际上有一个 API 服务可以让您托管自己的服务,以便在 WhatsApp 中发送不同类型的消息。您可以查看 UltraMsg。这是一项付费服务​​,但它可以发送您想要的通知。您可以查看他们的网站或查看本教程/评论视频。我真的不知道该用什么词:

    https://www.youtube.com/watch?v=9bdiUBuIH0o&t=138s

    【讨论】:

      【解决方案2】:

      我相信您在这里遗漏了两个概念。如果您想通过您的个人电话号码发送消息,您需要托管和运行您自己的解决方案(我认为您不会允许其他人获取您所有的东西)。

      如果您要求服务提供商为您设置号码并为此提供网关服务,则有多种选择。谷歌他们。你会发现两个选项; Facebook/Whatsapp API 连接了提供商和“搭便车者”,它们会为您设置成本。

      您提到的解决方案称为呼叫我机器人,它只是发送自我通知而不是向第三方发送消息。我正在托管一个类似的解决方案 (https://github.com/inUtil-info/whin-use-cases),但情况相同。为防止跨度,您不得向除您以外的任何人发送消息。

      【讨论】:

        猜你喜欢
        • 2013-09-04
        • 1970-01-01
        • 1970-01-01
        • 2018-09-01
        • 2015-07-08
        • 2021-01-22
        • 1970-01-01
        • 2016-04-15
        • 1970-01-01
        相关资源
        最近更新 更多