【发布时间】:2026-01-15 22:45:01
【问题描述】:
我有这个 api
public function airtime()
{
$send =
file("https://www.example.com/APIQueryV1.aspUserID=CK123&
APIKey=456&OrderID=789..............");
if($send)
{
return $status->ORDER_COMPLETED;
}
return $status->ORDER_COMPLETED;
}else return $status->ORDER_CANCELLED;
我也这样写代码
<?php
if(isset(POST["aitime"])) {
$send file("https://www.example.com/APIQueryV1.aspUserID=CK123&
APIKey=456&OrderID=789.............");
if($send)
{
return $status->ORDER_COMPLETED;
}
echo "SENT";
}else echo "NOT SENT";
?>
这是预期的返回 json
{"date":"17th-Mar- 2019","orderid":"798","statuscode":"200","status":"ORDER_COMPLETED","remark":"Success","mobilenetwork":"MTN","mobilenumber":"081xxxxxxxxxxx"
,"ordertype":"100 Credit","amountcharged":"95","walletbalance":"863210.1"}
如果状态返回 ORDER_COMPLETED,我想知道发送的回显,或者如果状态返回其他内容但未得到正确,我想知道发送的回声,请需要帮助。
【问题讨论】:
-
file()不是正确使用的函数(它会在漂亮打印的 json 上中断)、curl 或 file_get_contents -
它工作..谢谢现在我想得到“状态”的值我有这个
if($send) { Print_r($send); } } echo $status;但没有工作我有这个json作为输出{"status":"INVALID_CREDENTIALS"}