【问题标题】:How to send message from WhatsApp in PHP with WhatsAPI Official?如何使用 WhatsAPI Official 从 PHP 中的 WhatsApp 发送消息?
【发布时间】:2015-06-22 17:08:28
【问题描述】:

我正在尝试使用 WhatsApi 官方库通过 WhatsApp 从 php 文件发送消息。我已经在我的 Apache Web 服务器中移动了该库,在文件夹调用测试中,如下所示:

whatsapp.php 文件就是这个:

    <?php
    require_once './src/whatsprot.class.php';
    $username = "1XXXXXXXXX";
    $password = "password";
    $w = new WhatsProt($username, "0", "My Nickname", true); //Name your application by replacing “WhatsApp Messaging”
    $w->connect();
    $w->loginWithPassword($password);
    $target = '1xxxxxxxxx'; //Target Phone,reciever phone
    $message = 'This is my messagge';
    $w->SendPresenceSubscription($target); //Let us first send presence to user
    $w->sendMessage($target,$message ); // Send Message
    echo "Message Sent Successfully";
?>

我在使用 new WhatsProt() 库时遇到了一些问题,它阻塞了所有代码(可能是套接字?)。

所以我的问题是,我该如何解决这个问题?如果没有,是否有任何其他解决方案可以从 pho 脚本发送消息?

【问题讨论】:

  • 你从 API 服务器得到什么响应?
  • 脚本在 $w ->connect(); 之前停止工作所以我无法得到回应!
  • 您没有收到任何错误?您的凭据或WhatsProt Class 可能有问题
  • 是否有简单的工具来检查凭据是否正确?
  • 没有官方 API

标签: php whatsapp


【解决方案1】:

您可以使用以下脚本从 PHP 的 whatsapp 发送消息。

https://github.com/venomous0x/WhatsAPI/tree/master/examples

Apache中配置源代码并运行examples/whatsapp.php文件。

您已更改以下配置。

//simple password to view this script
$config['webpassword'] = 'MakeUpPassword';

$config['YOURNAME'] = array(
'id' => 'e807f1fcf82d132f9bb018ca6738a19f',
'fromNumber' => '441234567890',
'nick' => "YOURNICKNAME",
'waPassword' => "EsdfsawS+/ffdskjsdhwebdgxbs=",
'email' => 'testemail@gmail.com',
'emailPassword' => 'gmailpassword'
);

它对我有用..

【讨论】:

  • 谢谢。关于我应该做的动作/修改,你能更准确一点吗?
  • 你只需要做上面的配置就可以了。如果您遇到任何问题,请告诉我。
  • id 包含每 2 个字符重复的多个 % 是否正常?为什么在我的脚本中不需要 id ?
  • 是的,这很正常。 whatsapp 中的唯一身份需要 id。
  • @Jayson : github.com/venomous0x/WhatsAPI/tree/master/examples 网址无效。显示 404
【解决方案2】:

afaik 你现在最好写一个 python 项目的接口。例如。有一个在 python 中为你发送消息的微服务,你可以通过一些 json 请求或类似的方式调用它们

看到这个项目,看起来很有希望:https://github.com/tgalal/yowsup

到目前为止,这似乎是唯一可行的选择,因为其他所有内容都已关闭或很有可能会禁止您的帐户

在此处查看讨论:

https://stackoverflow.com/a/46635985/533426

【讨论】:

    猜你喜欢
    • 2013-10-22
    • 1970-01-01
    • 2017-02-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-17
    • 2015-04-05
    • 1970-01-01
    相关资源
    最近更新 更多