【发布时间】: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