allow_url_fopen =“开启”
我正在尝试通过使用simplexml_load_file()来读取Telenor API的XML响应,但是返回不起作用 “无法加载外部实体“ Auth_requestError 200Error”
可能是由于Telenor API响应时间太晚,所以我尝试使用计时器但遇到了相同的问题
function simplexml_load_file_from_url($url, $timeout = 5){
$opts = array('http' => array('timeout' => (int)$timeout));
$context = stream_context_create($opts);
$data = file_get_contents($url, false, $context);
if(!$data){
trigger_error('Cannot load data from url: ' . $url, E_USER_NOTICE);
return false;
}
return simplexml_load_string($data);
}
$url = "https://telenorcsms.com.pk:27677/corporate_sms2/api/auth.jsp?msisdn=234234234234&password=4234234234234234324234";
$response = simplexml_load_file_from_url ($url);
if($response && substr($response->response,0,5)!=="Error")
{
return $response->data;
}