问题
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.
回答1:
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.
回答2:
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).
回答3:
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)
回答4:
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.
来源:https://stackoverflow.com/questions/30301030/how-to-receive-gps-data-from-device-with-php