我正在使用来自 github 和 examples/whatsapp.php 的 whatsapi。我已经正确配置了我的号码,密码等...
但是,当我执行程序时,登录后,当我尝试选择应该获取我的联系人和组的用户时,JS 错误“错误:AJAX 请求出错。XML/Json 格式不好。过来。
在检查 firbug 控制台时,我收到以下 php 错误消息;
注意:未定义的索引:C:\Program Files\EasyPHP-DevServer-14.1VC11\data\localweb\Landshoppe\WAPP\Chat-API-master\examples\whatsapp.php中的 id 在第321行
{"success":true,"类型”:“联系人”,“数据”:....
调用它的函数是
public function __construct(array $config)
{
$this->config = $config;
if ($_SERVER['REQUEST_METHOD'] == "POST") {
try {
$this->inputs = $this->cleanPostInputs();
if (isset($this->inputs['from'])) {
$this->from = $this->inputs['from'];
if (!array_key_exists($this->from, $this->config)) {
exit(json_encode(array(
"success" => false,
'type' => 'contacts',
"errormsg" => "No config settings for user $this->from could be found"
)));
} else {
$this->number = $this->config[$this->from]['fromNumber'];
// --This is the Line-- $this->id = $this->config[$this->from]['id'];
$this->nick = $this->config[$this->from]['nick'];
$this->password = $this->config[$this->from]['waPassword'];
$this->wa = new WhatsProt($this->number, $this->nick, false);
$this->wa->eventManager()->bind('onGetMessage', array($this, 'processReceivedMessage'));
$this->wa->eventManager()->bind('onConnect', array($this, 'connected'));
$this->wa->eventManager()->bind('onGetGroups', array($this, 'processGroupArray'));
}
}
} catch (Exception $e) {
exit(json_encode(array(
"success" => false,
'type' => 'contacts',
"errormsg" => $e->getMessage()
)));
}
}
}
之后,所有组和联系人都在其中定义!但程序因 JSON 错误而暂停!
那么我应该怎么做才能纠正'未定义的索引ID'?