Delphi Client:
procedure TForm7.Button7Click(Sender: TObject);
var
code : Integer;
sResponse : String;
Json : String;
JsonToSend : TStringStream;
begin
Json := '{"email" : "[email protected]", "password" : "123testar"}';
JsonToSend := TStringStream.Create( UTF8Encode(Json) );
try
IdHTTP1.Request.Method := 'POST';
IdHTTP1.Request.ContentType := 'application/json';
IdHTTP1.Request.ContentEncoding := 'utf-8';
try
sResponse := IdHTTP1.Post('http://localhost/webservice/receber.php', JsonToSend);
except
on E: Exception do
begin
Memo1.Lines.Add('Error on request: '#13#10 + e.Message);
Exit;
end;
end;
Memo1.lines.clear;
Memo1.lines.add(sResponse);
finally
JsonToSend.Free();
end;
end;
PHP Server:
<?php
$jason_data = file_get_contents('http://localhost/webservice/receber.php');
$decoded_data = json_decode($json_data);
print_r($decoded_data);
?>
But I did not succeed, would anyone know how to make it work?