I've written a test php script located in a remote server of mine, and I am using Delphi code to do a Http_Post to that php file.
It works perfectly when I am doing it on a local server, but fails with a
Socket Error #10061 - Connection Refused
error.
Here is the code I am using to do the Http Post :
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;
The url is reachable fro, browser and other applications viz. [Tested with an android app with the same php script]
Url : http://pbcserver.dlinkddns.com/users/priyabrata/contest.php
Php Script :
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));
}
New Observation :
When I run the app from within Delphi, the post doesn't work and get the above error,however when I run the created .exe from Windows like any other app, it works perfectly!