如何使用 WhatsAPI Official 用 PHP 从 WhatsApp 发送消息? [英] How to send message from WhatsApp in PHP with WhatsAPI Official?

查看:85
本文介绍了如何使用 WhatsAPI Official 用 PHP 从 WhatsApp 发送消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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:

whatsapp.php 文件就是这个:

The file whatsapp.php is this one:

    <?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() 库时遇到了一些问题,它会阻止所有代码(可能是套接字?).

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

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

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

推荐答案

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

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

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

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

Configure the source code in Apache and run examples/whatsapp.php file.

您更改了以下配置.

//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'
);

它对我有用..

这篇关于如何使用 WhatsAPI Official 用 PHP 从 WhatsApp 发送消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆