Php 执行后如何知道file()请求的状态
我有这个apiPhp 执行后如何知道file()请求的状态,php,arrays,json,api,file,Php,Arrays,Json,Api,File,我有这个api public function airtime() { $send = file("https://www.example.com/APIQueryV1.aspUserID=CK123& APIKey=456&OrderID=789.............."); if($send) { return $status->ORDER_COMPLETED; }
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";
?>
我想知道echo发送的状态是否返回订单_COMPLETED或其他信息如果状态返回其他信息但没有得到正确的信息,请需要帮助
public function airtime()
{
$send =
file("https://www.example.com/APIQueryV1.aspUserID=CK123&
APIKey=456&OrderID=789..............");
if($send) {
return $status->ORDER_COMPLETED; //return back from this function
}
//The code will only reach here if not completed
return $status->ORDER_CANCELLED;
}
$result = airtime();
//Prints out value of `$status->ORDER_COMPLETED` or `$status-
//>ORDER_CANCELLED`
echo $result;
代码无法正常工作,因为没有在任何地方定义
$status
,但上面是基于真或假的返回方式($send
)
代码不能正常工作,因为
$status
没有在任何地方定义,但上面是基于真或假的返回方式($send
)file()
不是正确的函数(它会破坏漂亮打印的json)、curl或file\u get\u content。谢谢,现在我想获得“status”的值我有这个if($send){Print_r($send);}}echo$status
但不起作用我有这个json作为输出{“status”:“INVALID_CREDENTIALS”}
file()
不是正确的函数(它会在打印精美的json上中断),curl或file_get_content可以工作..谢谢,现在我想得到“status”的值,我有这个if($send){Print_r($send)}}echo$状态代码>但不起作用我将此json作为输出{“状态”:“无效的\u凭证”}
public function airtime()
{
$send =
file("https://www.example.com/APIQueryV1.aspUserID=CK123&
APIKey=456&OrderID=789..............");
if($send) {
return $status->ORDER_COMPLETED; //return back from this function
}
//The code will only reach here if not completed
return $status->ORDER_CANCELLED;
}
$result = airtime();
//Prints out value of `$status->ORDER_COMPLETED` or `$status-
//>ORDER_CANCELLED`
echo $result;