How to receive GPS data from device with PHP? - php

I have a car GPS device, the only thing I can change is the IP-address.
Is it possible to have shared hosting with a dedicated IP-address (that part is possible) and then to have a PHP script that picks up the data that is being send?
So what is in my mind:
GPS device send gps data to IP-address.
That IP-address has a PHP script that picks up the data and use it.
As requested a little bit more detailed.
There is a question that is exactly the same but don't have an answer: how-to-get-data-from-gps-and-send-to-server-and-how-save-to-database
It is a Chinese car GPS device with a standard IP address. So it sends data to that IP address. Then they give us a website where we can login with the product code and we can see the GPS location.
It is possible to change the IP address in this device. I have found shared hosting with a dedicated IP address, but that means the IP address just replaces the URL so it works just as an URL, so it is not that I can change the server and install something like openGTS.
But I have no idea what kind of data (I don't think it is just GET or POST data) this device is sending. So I am wondering if the GPS is sending the data to an IP address whether I have to do something special with java on that server or I am able to use a PHP script to pickup what the GPS device is sending? Once I get the data I know what to do with it. All I need is the data to be picked up by a PHP script.

There is not a shortcut as I was hoping. For a gps tracker device that sends TCP/UDP data to an ip address and port we really need a server. There will be no POST/GET data. The server will receive data through a port that needs to be decoded. But it was not as complicated as I thought. Even without any knowledge of Java I was able to install a software and manipulate it to my liking.
What I did:
Got a windows server (2012) hosting (6 months for free) so I could
try it out.
Downloaded opengts and followed their instruction manual exactly. And did not find it hard at all. It worked without having much headache
Once I got to the part where everything was working I could play around with the device and it was working fine. Ofcourse we need to know the protocol (the data) that the device is sending and decode so it can be saved in the database.

you need this:
The phone(Number) (with GPS).
A SmartPhone( Androir and develop your own APP) - (Like a Sub-Server).
A (Home Server) or (WebServer) with MySQL(Data Base).
A Script with PHP in your Server or WebPage(Point 3).
So:
The (Phone Number with GPS) just wait for a call or something to send the "Data".
(The SmartPhone) get the data from (The Phone Number with GPS).
Read the Message Board ONLY from your (Phone Number with GPS) with (your Own APP Android) AND Process the "Data" with (your Own Android APP).
Get the "String" of (Lat) and (Lon) Coordinates Or ALL your need from the (Message Board) and SEND to your (PHP Script) using HTTP request to your (Home Server or WebPage) From your (SmartPhone) Using your (Own Android APP).
Work with your (PHP Script) and save in your (MySQL Data Base).
... you can do everything now with the "Data", like show with other php script and google maps api, or use for a desktop application on java, or visual basic, etc..etc..., or all you wish.
Note:
*Not use your (SmartPhone) for nothing, only for prossesing "Data" of ALL (Phone Numbers) your want Using your (Own Android APP) Reading the Message Board with Code, so your (SmartPhone) now is like a "Mini Server" and only works as an intermediary between your (Phone Number with GPS) and your (PHP Script) in your (Home Server or WebPage) with (MySQL Data Base).

You need to use Database, create php script (POST query) and update query into database when GPS position change, than you can have access to this position from database with another php script (GET and return json object)

If you have a shared hosting, you'll only have the 80 port open. So in your device, you will need to make HTTP requests to that IP on port 80.
In order to make a correct HTTP request, read the RFC2616 (http://www.w3.org/Protocols/rfc2616/rfc2616.html) to get started with HTTP protocol.
At minimum, you will need to provide a hostname and URI in your HTTP request.
On that URI, your PHP script will be able to read data and do something with it.

Related

send HTTPREQUEST from a website to a arduino

I want to send a value from my website to my arduino using httprequest.
as the image explain, i want to enter my site from a device (let's say mobile phone) and send a request to my arduino from my website (webserver)
so i'm having this problems:
1- how to address the arduino without dns, should i have a fixed ip address for my arduino, is there any way else ?
2- what is the PHP code that i need to let the website send the request ??
i know i can connect arduino to web using httpclient, but i want the reverse process, that is connect the website to arduino ( the website as client and a arduino as a server)
is there anyway to do that ?
thank you and sorry for my bad english
I've recently made a similar project with a Raspberry Pi. But this doesn't make a difference.
First be careful with my solution. Anybody can join on your device, if they have your IP and Port. It might be not the best solution, but it works pretty good.
So what I did is, I've set a DynDNS to my router, so that I doesn't have to change the IP in my script every time. You can get a DynDNS from your provider or you can use the free service No-IP. Next I set a static local IP adress to my arduino/pi via the settings on my router. Then I also set port-forwarding to the arduino/pi.
Then you should be able to access your arduino/pi via the internet. And if you have this, you can also control it via any website you want.
To accomplish an HTTP request in PHP, there will be a lot of possible solutions. But I prefer this:
$response = file_get_contents(YOUR_DYNDNSIP_AND_PORT)
https://www.w3schools.com/php/func_filesystem_file_get_contents.asp
You also can additionally can get a response via this function.
To protect your own network, you can use HTTP Basic Authentication, which you have to add a username and a password to the request. This make it difficulter to access your arduino.
I hope this might help you.

How to send data from website to web server on raspberry pi?

Let's say that I have a website somewhere over the internet. At my house there is a raspberry pi.
Can I send data from that website to that raspberry pi?
I have web server on that raspberry pi, and I tried sending a POST request from website, and it worked, but now anyone, who knows how to send POST request can just send that data to raspberry pi. I want to send that data to C++ program, that I'll write. How can I do it?
Can I do it another way, or somehow secure that POST request?
If you want to prevent your users from seeing that is being posted to the RasPi and from tampering with it, you'll need to send that data from the server, not from user's browsers. You can still do this by POSTing to some sort of web service on the RasPi, or you can cache the information on the web server and poll it from the RasPi. In either case, you should protect that flow by requiring that it take place over HTTPS (as opposed to plain-text HTTP) and authenticating the client using either a TLS client certificate or some sort of API key.
Use SSL (secure transmission) - not perfect but will stop a lot
Use a 'nonce' (https://security.stackexchange.com/questions/30519/prevent-cross-domain-form-submission-with-nonce plus google).
Filter requests not coming from the correct IP address (assuming your web server will have a fixed outgoing IP address). [Side note: this is fakable so not perfect]
Individually encrypt each instructions manually, including a shared private key on your webserver and a unique ID embedded in each message. If you get exactly the same encrypted message it's a repeat post can be safely be dropped.

Direct communication between php script to client (Windows or Android)

I am thinking about a scenario where I want to send a data packet from my php service (based on certain behaviour) to a client (can be Android or Windows) connected to it.
A device which is connected to the internet is going to have an ip address.
So is it possible to send a packet (using socket or else) to this ip directly (without polling from client end) and can this data be read from the client.
Scenario is like this :
Client A --------------Registers Own IP Address-----------------> Server
Client B --------------Registers Own IP Address-----------------> Server
Events :
Some changes occur in the database (say)
Server detects the affected client (via some algo),say Client A
Sends a packet to Client A
Client A <--------------Send Data Packet----------------- Server
Is this at-all possible ?
If yes, how effective can this be ?
Please note that, Push notifications is not applicable in my situation.
I am looking for a live (realtime) data transmission system between client and server (both ways).
Any suggestion, help will be useful. Thanx
Absolutely possible to have persistent sockets open.
but I would say this would fail in a hosted environment. GoDaddy etc shuts that down. Been there done that.
I would highly recommend choosing a programming language like java (Whatever you are comfortable with). It is only going to be 200 lines of code.

Windows Embedded Handhel 6.5 app development synchronize windows PC

What is the best alternative to synchronize an app on Windows Mobile 6.5 with SQL Server Compaq with an php aplication on a PC server.
The phone does not always have internet access beacouse coverage issues, also can be connected to a PC via USB.
The data are in a table in SQL Server Compaq on the phone, the data are text and a number, associated through an identifier. This is updated from time to time where there is no internet connection. Then this data update a database in SQL Server 2008 on a server that has internet access.
There is also the possibility to update the phone's data table from the server to add more data to be updated in the field.
I hope you understand me because English is not my native language.
I was thinking of using exchange to send emails with updated data or use a service like dropbox to keep an updated file and that file is processed.
Which approach is better?
I hope you can guide me.
thank you very much.
If you are running a SQLClient on the CE device that connects to a SQL server, the best solution is to use the SQL synchronization options. This is also called RDA, see for example: http://etutorials.org/Programming/building+solutions+with+the+microsoft+net+compact+framework/Part+II+Essential+Architectural+Concepts/Chapter+7.+Data+Synchronization/RDA/
If the databases on the device and on the server are not connected, the automatic ID generation on the device and the server create different unique IDs. These will result in a conflict, when you update the data from multiple sources. If you do not need to handle conflicts with multiple sources updating the same database, you may simple send the updates between the server and the client and vice versa on regular intervals using http GET/POST or simple socket server/client.
Usually sometimes disconnected devices use http or another network protocol to pull and push updates. Files are rarely used for push/pull updates.
As you used the php TAG for this question too, using http with a php server with a database in the background, you can use php to extract data sent via GET/POST and also provide data back to the device using xml (or another format).

Find the IP address using as3 and server side technology

I am trying to find the IP address using as3 in adobe Flash professional cs5.5 and I think it is not possible from AS3 without using any server side technology(maybe I am wrong).
But I don't know any server side technology like PHP..etc.
Can anyone provide an example?
you can get the Local Machine using JavaScript. and also you can develop server side script which will retirve your local machine IP address from request header.
But as per your comments on your question I think you required your local machine IP. it will be get using javascript. But this IP address is not gateway or server side displayed one. Because in home or some fire wall / proxy user has different IP to access internet and local mahcine ip will be LAN IP.
and Javascript code you can call using the External Interface.
Please search for Javascript and ExternInterface code example you will find out many code example through google.
There's a simple and clean way to dynamically get the domain name, but not the IP, of the server hosting the SWF file.
You can use the domain property of the LocalConnection class.
try:
import flash.net.LocalConnection;
var lc:LocalConnection = new LocalConnection();
trace(lc.domain); // Outputs domain name of the hosting server, or `localhost` if ran locally.

Categories