Service number development-GET user location information
In the development of public numbers, access to user location information is a very common feature needs, through the user's location information, can do some map navigation, as well as the LBS-based marketing activities.
The following describes the principles and procedures for obtaining user location information in the service number.
Principle
1. Location Information Acquisition process
2. Location information messages
gh_public_member_account
oNEGGwGfl8f5xMEqVHToL63LDL40
1444035882
28.701618 event
LOCATION
115.818817
30.000000
Parameter description:
Parameters |
Description |
Tousername |
Developer Number |
Fromusername |
Sender account (one OpenID) |
Createtime |
Message creation time (integer type) |
Msgtype |
Message type, Event |
Event |
Event Type, location |
Latitude |
Geographical latitude |
Longitude |
Geographic longitude |
Precision |
Location accuracy |
Get location Information step
1. Application for service number certification
Access to advanced services can only be obtained if the service number is certified.
2. Turn on the user location information acquisition function
Developer Center, get the user's location
3. weiphp location information message processing.
1. Configure the Service number development interface
The server will push the interaction between the user and the event message through this interface to the SP server.
2. Process the location message in the Weixincontroller indexaction.
Convert the XML message into a PHP array, and then remove the latitude and longitude information for use.
$content = file_get_contents (' php://input '); $data = new \simplexmlelement ($content); foreach ($data as $key + = $v Alue) { $this->data [$key] = Strval ($value);} To use data["longitude"]; data["Latitude"].
Location information Development
The above describes the service number development-to obtain user location information, including the content, I hope that the PHP tutorial interested in a friend helpful.