-17-
v7.0
Software
3.10. HTTP client
3.10.1. HTTP connections
HTTP is a great protocol because it is a standard, simple and light way to send information to web servers.
Libelium has created a little web service in order to allow 4G, 3G, GPRS, GPRS+GPS, NB-IoT / Cat-M or WiFi modules
to test the HTTP mode. This web service is a little code, written in PHP, which is continuously listening to the
HTTP port (port number 80) of our test server “pruebas.libelium.com”. This is a kind of RESTful service. These
communication modules can send HTTP instances to our web service.
HTTP instances should have the following structures so that our web service can understand.
GET method
In GET method the data are sent to the server append to the main URL with the ‘?’ character. The base sentence
to perform GET method is shown below:
pruebas.libelium.com/getpost_frame_parser.php?<variable1=value1>&<variable2=value2>&<...>&
view=html
Where:
•
getpost_frame_parser.php?
: It is the main URL, where the web service is running.
•
<variable1=value1>
: It is a couple with the variable name and value which we want the web service to parse.
•
view=html
: It is an optional argument. It shows a “pretty” response (HTML formatted).
All arguments must be separated by “&”. The variable name and value must be separated by “=”.
Some examples:
pruebas.libelium.com/getpost_frame_parser.php?var1=3.1415
pruebas.libelium.com/getpost_frame_parser.php?var1=3.1415&view=html
pruebas.libelium.com/getpost_frame_parser.php?var1=3.1415&var2=123456&var3=hello&view=html
POST method
Unlike GET method, with POST method the data are sent to the server into an extra data field. The URL only
includes the site name and the PHP direction:
pruebas.libelium.com/getpost_frame_parser.php
The data field is very similar as the used in GET method:
<variable1=value1>&<variable2=value2>&<...>&view=html
Where:
<variable1=value1>
: It is a couple with the variable name and value which we want the web service to
parse.
All arguments must be separated by “&”. The variable name and value must be separated by “=”.
Some examples of data field:
pruebas.libelium.com/getpost_frame_parser.php?variable1=3.141592
pruebas.libelium.com/getpost_frame_parser.php?var1=3.1415&var2=123456&var3=hello