使用php发送whatsapp消息 [英] send whatsapp message using php
问题描述
嗨. 我想使用php发送whatsapp消息.我运行这段代码
hi. i want to send whatsapp message using php. i run this code
<?php
require_once 'Chat-API-master/src/whatsprot.class.php';
$username = "6285648145xxx";
$nickname = "ardi";
$password = "password"; // The one we got registering the number
$debug = true;
// Create a instance of WhastPort.
$w = new WhatsProt($username, $nickname, $debug);
$w->connect(); // Connect to WhatsApp network
$w->loginWithPassword($password); // logging in with the password we got!
$target = '62811304xxxx'; // The number of the person you are sending the message
$message = 'Hi! :) this is a test message';
$w->sendMessage($target , $message);
?>
但是我在浏览器中得到了这段代码
tx <stream:features></stream:features>
tx <auth user="6285648145xxx" mechanism="WAUTH-2"></auth>
rx <from s.whatsapp.net=""></from>
rx <stream:features></stream:features>
rx <challenge>376a507c7e915642d85255fe96cb1d101fa23819</challenge>
tx <response>200e09fa50b7c6a3fa3416878f1e165e8d7670f054ddeaa1c77278a5f8e5b881f4f9f75dce809f42cbdcf17931db8c15641399488b90e9cb74e87de94560802f98bb028af9b5967403fb278c28e06c</response>
Fatal error: Maximum execution time of 30 seconds exceeded in D:\XAMPP\htdocs\waonline\Chat-API-master\src\whatsprot.class.php on line 2609
怎么了?请给我解决方法.谢谢
what's wrong?? please give me sollution. thanks
推荐答案
官方文档说来使用他们的wa.me URL ,所以我们就来检查一下: http://wa.我/?text = mytest .你看到了什么?您看到错误页面了吗?这是我看到的:
The official documentation says to use their wa.me URL, so let's just check it out: http://wa.me/?text=mytest. What do you see? Do you see an error page? This is what I see:
我们找不到您要查找的页面
We couldn't find the page you were looking for
看起来您正在寻找一个不存在的页面.或我们可能刚刚删除的页面.无论哪种方式,请返回或确保检查URL,您的拼写并重试.
Looks like you're looking for a page that doesn't exist. Or a page we might have just deleted. Either way, go back or be sure to check the url, your spelling and try again.
因此,简而言之,请勿使用wa.me URL .使用api.whatsapp.com
URL,如下所示之一:
So, in short, DO NOT use the wa.me URL. Use the api.whatsapp.com
URL, like one of these:
https://api.whatsapp.com/send ?text = YourShareTextHere& phone = 123
这两个对我来说都很完美!
These both work perfectly for me!
If you are interested in watching a project that keeps track of these URLs, then check us out!: https://github.com/bradvin/social-share-urls#whatsapp
这篇关于使用php发送whatsapp消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!