简体   繁体   English

使用 PHP 通过 WhatsApp API 发送消息

[英]Sending a message by the WhatsApp API using PHP

I am trying to send a message by the WhatsApp API using PHP.我正在尝试使用 PHP 通过 WhatsApp API 发送消息。 I have the WhatsApp password and am getting by WART using the following code:我有 WhatsApp 密码,并使用以下代码通过 WART 获取:

<?php 
require "whatsapp.class.php";
// DEMO OF USAGE
$wa = new WhatsApp("91XXXXXXXXXX", "XXX-XXX", "Nick Name");
$wa->Connect();
$t = $wa->Login();
$wa->Message("5","91XXXXXXXXXX","Good code");
echo "Message sent";
?> 

I did not change anything in the whatsapp.class.php file.我没有更改 whatsapp.class.php 文件中的任何内容。

My files are:我的文件是:

http://vvsindia.com/stackoverflow/whatsapp.class.txt
http://vvsindia.com/stackoverflow/func.txt
http://vvsindia.com/stackoverflow/decode.txt

For your convenience to view while browsing, I just uploaded them as a txt file, but originally these are PHP files.为了方便大家浏览时查看,我只是把它们上传为txt文件,但原来这些都是PHP文件。

Using the above code I was not able to send any message.使用上面的代码我无法发送任何消息。 What could the issue be?可能是什么问题?

You can use the below script to send a message from WhatsApp in PHP.您可以使用以下脚本在 PHP 中从 WhatsApp 发送消息。

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

Configure the source code in Apache and run examples/whatsapp.php file.Apache配置源代码并运行examples/whatsapp.php文件。

You have to change the 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' => 'testemail@gmail.com',
'emailPassword' => 'gmailpassword'
);

You should rather try this quick and easy interface API:你应该试试这个快速简单的接口 API:

https://www.mashape.com/motp/whatsapp-pusher https://www.mashape.com/motp/whatsapp-pusher

As given in the documentation, sending a text message to a WhatsApp user would be a one-step process.如文档中所述,向 WhatsApp 用户发送短信将是一个一步过程。 Below is a sample cURL call to send a text message to a WhatsApp user.以下是向 WhatsApp 用户发送短信的示例 cURL 调用。

curl -XPOST 'http://api.dial2verify.com/WHAPP/SEND/<API_KEY>/<Phone_ISD>' \
  -d 'Msg=Text to image URL here'

To get the API key, you are required to drop a request to hello@dial2verify.in, and they would provide you a free API key.要获取 API 密钥,您需要向 hello@dial2verify.in 发送请求,他们会为您提供一个免费的 API 密钥。

Phone_ISD: should be a complete phone number including ISD code (for example, 919922003300). Phone_ISD:应该是一个完整的电话号码,包括 ISD 代码(例如,919922003300)。

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

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