0
所以我做了这个脚本,基本上是一个命令。未定义指数天气
它所做的是,用户使用$ arg定义命令“weather”,其中$ arg就是所说的内容。然后对生成的json进行解码,然后仅从json发送包。但它说“位置”和“温度”是不确定的。
有人可以帮我解决这个问题吗?数据包得到正确发送,但数据包发送时不显示位置或温度。数据包sm =发送消息。
这里是代码
if($cmd == 'weather'){
$file = file_get_contents('http://weather3.pricop.info/api.php?city=' . $arg);
$weather = json_decode($file, true);
$user->sendPacket("%xt%sm%-1%0%" . " Temperature for " . $weather["location"] . "%" . " will be " . $weather["temperature"] . "%");
}
请出示'的var_dump($文件);' - 我们真的不能调试为什么你的JSON也不是没有看到JSON ;-) – DaveRandom
HTTP解码权://prntscr.com/1io71v – user2524169