Re: webservice implementation using php
Posted:
Fri Mar 01, 2019 8:11 am
by Antonio Linares
Thank you Carles!
Now lets enhance our webservice to inspect any provided parameters:
webservice.php
- Code: Select all Expand view
<?php
header("Content-Type:application/json");
$response[ 'status' ] = "ready";
$response[ 'about' ] = "FiveTech Software S.L. webservice";
$response[ 'method' ] = $_SERVER[ 'REQUEST_METHOD' ];
$response[ 'params' ] = $_GET;
echo json_encode( $response );
?>
We can try it this way:
http://www.fivetechsoft.com/webservice.php?tablename=usersAnd we get this:
{"status":"ready","about":"FiveTech Software S.L. webservice","method":"GET","params":{"tablename":"users"}}
Re: webservice implementation using php
Posted:
Fri Mar 01, 2019 8:19 am
by Antonio Linares
Lets asume that we want to open a remote database table and retrieve a SQL query:
http://www.fivetechsoft.com/webservice.php?database=test&tablename=users&username=fivetech&password=1234&sql=select%20*We get this:
{"status":"ready","about":"FiveTech Software S.L. webservice","method":"GET","params":{"database":"test","tablename":"users","username":"fivetech","password":"1234","sql":"select *"}}
Re: webservice implementation using php
Posted:
Fri Mar 01, 2019 8:21 am
by hmpaquito
Buenos días Antonio,
Interesante tema.
¿ Conectaremos con nuestro sistema fwh, al menos a nivel de datos (dbf) ?
¿ Podremos ejecutar un .exe fwh que genere un json ?
Salu2
Re: webservice implementation using php
Posted:
Fri Mar 01, 2019 8:26 am
by Antonio Linares
Paco,
Carles has already published the basic code to use it
viewtopic.php?p=219690#p219690Now we are going to enhance our webservice to offer databases tables management
Re: webservice implementation using php
Posted:
Fri Mar 01, 2019 8:42 am
by Antonio Linares
A very basic example to allow SQL queries from our webservice:
webservice.php
- Code: Select all Expand view
<?php
header("Content-Type:application/json");
$response[ 'status' ] = "ready";
$response[ 'about' ] = "FiveTech Software S.L. webservice";
$response[ 'method' ] = $_SERVER[ 'REQUEST_METHOD' ];
$response[ 'params' ] = $_GET;
$server = "localhost";
$database = $response[ 'params' ][ 'database' ];
$user = $response[ 'params' ][ 'username' ];
$password = $response[ 'params' ][ 'password' ];
$sql = $response[ 'params' ][ 'sql' ];
$conn = mysqli_connect( $server, $user, $password, $database );
if( ! $conn )
$response[ 'error' ] = mysqli_connect_error();
else
{
$response[ 'result' ] = mysqli_query( $conn, $sql );
mysqli_close( $conn );
}
echo json_encode( $response );
?>
Re: webservice implementation using php
Posted:
Thu Mar 28, 2019 8:13 pm
by gabrielgaspar.dev
Hello, good afternoon!
I am new here and i wanted to know what i need to access "https"?
I have the Fivewin 17.07 and xHarbour 1.2.3 and BCC 7
Re: webservice implementation using php
Posted:
Thu Mar 28, 2019 9:19 pm
by cnavarro
You are welcome
Gabriel, explain better what you need