在这里,我尝试获取curl请求,它在某些服务器上可以使用,在某些服务器上不能使用,但是可以在本地主机上使用。 当我显示错误消息味精时说
“无法连接到api.lankagate.gov.lk端口8280:连接被拒绝”。
这是我的功能:
function get_on_going_vehicle_number() {
$vehicle_category = 1;
$xml_data = '<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://schemas.conversesolutions.com/xsd/dmticta/v1">
<soapenv:Header/>
<soapenv:Body>
<v1:GetOnGoingVehicleNo>
<v1:vehicleCategory>' . $vehicle_category . '</v1:vehicleCategory>
</v1:GetOnGoingVehicleNo>
</soapenv:Body>
</soapenv:Envelope>';
$URL = "http://api.lankagate.gov.lk:8280/GetOnGoingVehicleNoDMT/1.0";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: text/xml',
'Authorization: Bearer 7655a410-d019-3f09-b214-08c40e737af0'
));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_PORT,8280);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
if (curl_error($ch)) {
$error_msg = curl_error($ch);
echo $error_msg;
}
return $output;
curl_close($ch);
}
我们尝试远程登录:
working server: > telnet api.lankagate.gov.lk 8280 Trying 43.224.126.66...
Connected to api.lankagate.gov.lk.
Escape character is '^]'.
Connection closed by foreign host. Non working server:
user@dwp-s01:~$ telnet api.lankagate.gov.lk 8280
服务器无法正常工作
Trying 192.168.12.117...
telnet: Unable to connect to remote host: Connection refused
user@dwp-s01:~$
尝试使用其他IP:192.168.12.117 请给我一个解决方案
答案 0 :(得分:0)
这里可能有多个问题。
我想您不能在api.lankagate.gov.lk上禁用防火墙。因此,请尝试其他端口。
答案 1 :(得分:0)
extension UITextField {
open override func awakeFromNib() {
super.awakeFromNib()
if UserDefaults.languageCode == "ar" {
if textAlignment == .natural {
self.textAlignment = .right
}
}
}
}
似乎是本地网络。
因此,您可能已经在主机文件中指出了该IP,并且必须将其删除
示例:
192.168.12.117
或c:\Windows\System32\Drivers\etc\hosts
/etc/hosts
或者您的网络路由器或代理(192.168.12.117)阻止您进行连接。