这是我的代码
<?php
$allBots = require_once 'botsPath.php';
$method = $_SERVER['REQUEST_METHOD'];
$request = explode("/", substr(@$_SERVER['PATH_INFO'], 1));
//var_dump($allBots);die;
$botName = array_shift($request);
$res = '';
$botJid = '';
$returnMessageTo = '';
if(isset($allBots[$botName])){
require_once $allBots[$botName]['path'];
$botObject = new $allBots[$botName]['class'];
$botJid = $allBots[$botName]['jid'];
switch (strtolower($method)){
case 'put':
$returnMessageTo = $userName = $request[1];
$res = $botObject->subscriptionCreated($userName);
break;
case 'post':
$postType = $request[0];
$postMessage = file_get_contents("php://input");
$postXml = new SimpleXMLElement($postMessage);
$returnMessageTo = $from = $postXml['from'];
if(strtolower($postType) == 'presence'){
$status = $postXml->status;
$text = $postXml->text;
$res = $botObject->presenceReceived($from, $status, $text);
}else{
$message = $postXml->body;
$res = $botObject->messageReceived($from, $message);
}
break;
case 'delete':
$returnMessageTo = $userName = $request[1];
$res = $botObject->subscriptionDeleted($userName);
break;
}
}
//else, we really do not care
header('Content-type: application/xml');
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?><message from='$botJid' to='$returnMessageTo'><body><![CDATA[$res]]></body></message>";
昨天当我在我的服务器上托管它时很好,
但现在我收到了错误:
此页面包含以下错误:
第1行第3行的错误:文档末尾的额外内容 下面是第一个错误的页面呈现。
第3行没有写任何内容。 现在已经摸不着头脑了