WeChat service number development-GET user location information

Source: Internet
Author: User
Tags cdata
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.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.