The principle and procedure of obtaining the location information of the user by WeChat, obtaining the location _php tutorial

Source: Internet
Author: User
Tags cdata

Get geo-location information by the principles and procedures


In the public service number development requirements often have access to user location information function, through the user's location information, can do some map navigation, and based on LBS marketing activities.

The following is to introduce the service number to obtain the User location information principles and procedures.

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:

parameter description
tousername developer number
fromusername Sender account (one OpenID)
createtime message creation time (integral type)
msgtype message type, event
event event type, location
latitude geographic 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"].

The above through the text and graphics to show you how to obtain the user's geographical location information principles and procedures, I hope you like.

http://www.bkjia.com/PHPjc/1071234.html www.bkjia.com true http://www.bkjia.com/PHPjc/1071234.html techarticle the principle and procedure of obtaining the location information of the user, obtaining the location of the information in the development of the public service number often has the function of obtaining the user's location, through the user's location letter ...

  • 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.