通过HTTP-POST[通过互联网]从Delphi应用程序连接到php脚本
我已经在我的远程服务器上编写了一个测试php脚本 我正在使用Delphi代码对该php文件进行Http_发布 当我在本地服务器上执行此操作时,它可以完美地工作,但在 套接字错误10061-连接被拒绝 错误 下面是我用于执行Http Post的代码:通过HTTP-POST[通过互联网]从Delphi应用程序连接到php脚本,php,delphi,delphi-xe5,Php,Delphi,Delphi Xe5,我已经在我的远程服务器上编写了一个测试php脚本 我正在使用Delphi代码对该php文件进行Http_发布 当我在本地服务器上执行此操作时,它可以完美地工作,但在 套接字错误10061-连接被拒绝 错误 下面是我用于执行Http Post的代码: function TForm1.doPost(Url : String): string; var lHTTP: TIdHTTP; lParamList: TStringList; begin lParamList := TStringL
function TForm1.doPost(Url : String): string;
var
lHTTP: TIdHTTP;
lParamList: TStringList;
begin
lParamList := TStringList.Create;
lParamList.Add('service_test=Testing Server');
lHTTP := TIdHTTP.Create(nil);
try
Result := lHTTP.Post(Url, lParamList);
prgView.StepIt;
finally
lHTTP.Free;
lParamList.Free;
end;
end;
url可从浏览器和其他应用程序访问,即。[使用具有相同php脚本的android应用程序进行测试]
网址:
Php脚本:
if (isset($_POST["service_test"])){
$val = $_POST["service_test"];
if ($val == "Testing Server"){
$response["Success"] = "1";
echo (json_encode($response));
}
else{
$response["Success"] = "0";
echo (json_encode($response));
}
}
else{
$response["Success"] = "0";
echo (json_encode($response));
}
新的观察结果:
当我在Delphi中运行应用程序时,帖子不起作用,并且会出现错误
但是,当我从Windows运行创建的.exe时,出现了上述错误,如
任何其他应用程序,它的工作完美
您在这里有一个空格service\u test=Testing Server使用service\u test=Testing%20Server进行尝试。没有帮助。遇到相同的错误。如果看不到Url和php脚本,很难提供帮助。您的isset$\u GET[…]无法让您执行HTTP.Post。我无法通过浏览器或delphi连接到您的服务器。获取错误:网络超时服务器pbcserver.dlinkddns.com花费的时间太长,无法发布响应。该网站可能暂时不可用,请稍后再试。如果您无法访问任何其他网站,请检查网络/互联网连接。如果您的计算机或网络受到防火墙或代理的保护,请确保允许Firefox访问Internet。