Alrighty, let's try this again!
I'm currently developing an application that will be relying on a web server for some of its functionality. I'm interested,开发者_如何学Go however, in transmitting the user's location to other users who request it. What would be the best possible way to implement this in the application? Thank you! :D
If I were making this application for a standard linux server, I would have a MySQL table called locations, or users. Inside that table, I would store the device id, the latitude, longitude, and date of the users' location. Then, when a user's location changes, update the entry in the table using a HTTP request to a PHP script.
As far as the programming, look into NSURLRequests and NSURLConnections. You would need to do a POST or GET, including this information. This might be an example of the requests:
{ /* Update Location: http://hostname/path/location.php */
action = "updatelocation",
deviceid = "635262f796d3fe35229275d5835bf42861c33f23",
latitude = 0,
longitude = 0
}
Processing on the server wouldn't be too hard. That should at least get you started on storing the locations. Letting other users request the locations would be a little harder.
精彩评论