如何使用 WhatsAPI Official 用 PHP 从 WhatsApp 发送消息?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29672255/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 00:30:48  来源:igfitidea点击:

How to send message from WhatsApp in PHP with WhatsAPI Official?

phpwhatsapp

提问by I love coding

I'm trying to use the WhatsApi Official library to send a message via WhatsApp from a php file. I've moved in my Apache web server the library, in a folder call test, like this:

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

enter image description here

在此处输入图片说明

The file whatsapp.php is this one:

文件 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";
?>

I'm facing some problem with the library new WhatsProt(), which blocks all the code (may be sockets ?).

我正面临库 new WhatsProt() 的一些问题,它阻止了所有代码(可能是套接字?)。

So my question is, how can I fix this problem ? If no, are there any other solution to send message from a pho script ?

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

采纳答案by Jayson

You can use below script to send message from whatsapp in PHP.

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

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

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

Configure the source code in Apacheand run examples/whatsapp.phpfile.

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

You have change below configurations.

您更改了以下配置。

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

and

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

It's working for me..

它对我有用..

回答by Toskan

afaik you are probably better off currently writing an interface to a python project. E.g. have a microservice that does sending of messages for you in python, and you call them via some json request or similar

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

see this project, looks promising: https://github.com/tgalal/yowsup

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

it seems like the only viable option so far, as everything else was shut down or has a high probability to get your account banned

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

see discussion here:

请参阅此处的讨论:

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

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