WeChat public platform Message Interface Development (30) public comments merchant information group buying and coupon query

Source: Internet
Author: User
Public platform development public platform developer public platform development model public comments merchant information group buying City coupon

1. obtain data

Public comments released the first O2O developer platform in China-"public comments Developer Platform". Developers and applications can access the local merchant information, merchant reviews, discounts, and group purchases on the public comments platform.
Through the public comments API, developers can access local merchant information, merchant reviews, discounts, group purchases, and other content on the public comments platform based on users' real-time needs. In the future, they will also open up services such as merchant reservations and e-membership cards to explore more possibilities for cooperation with developers.

Developer Platform application address http://developer.dianping.com/

Three steps are required for developers to apply for the public comments API:

Step 1: register a developer.
Step 2: After successful registration, you can obtain the App key and have the permission to use the test data. please refer to the developer agreement and review specifications for application development.
Step 3: submit the application review on the application console. after the application is approved by the public comments, the App key is upgraded to the official permission and automatically switches to the official data.


II. program development

Currently, public comments mainly provide the following interfaces:

These interfaces can be integrated on the public platform.
The only development difficulty is described as follows:

API request signature

Overview
The public comments API needs to be accessed through a signature. the signature process is to generate the request parameter string and the APP key according to a certain signature algorithm, as a new request parameter to improve tamper-proofing during access. For details about how to generate a signature value, see the following description.

URL signature generation rules
The valid access URLs of all public comments include the following three parts:
1. resource access path, such as/v1/deal/find_deals;
2. request parameters: the required parameter names and parameter values for the API are param = value. Multiple request parameters are connected &.
For example, deal_id = 1-85462 & appkey = 00000;
3. signature string generated by the signature algorithm

The signature algorithm is as follows:
1. sort all request parameters except appkey in alphabetical ascending order;

Define ('appkey', 'xxxxxxxx'); define ('secret', 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'); define ('URL', 'http: // response '); $ params = array ('format' => 'json', 'City' => 'Shanghai', 'latitude '=> '31. 2204200000392 ', 'longyun' => '100. 41163000018 ', 'radius' => '000000', 'offset _ type' => '1', 'sort '=> '7 ', 'Has _ deal' => '1', 'has _ coupon '=> '1', 'Category' => 'food', 'region '=> 'changning District ', 'limit' => '20', 'keyword' => 'Thai food'); ksort ($ params );

2. connect the preceding sorted parameter table to a string, for example, key1value1key2value2key3value3... keyNvalueN;

$codes = APPKEY; $queryString = ''; while (list($key, $val) = each($params)){ $codes .=($key.$val); $queryString .=('&'.$key.'='.urlencode($val));} $codes .=SECRET;

3. use the app key as the prefix and app secret as the suffix. calculate the string using SHA-1 and convert it to hexadecimal encoding;
4. the signature string is obtained after the string is converted to a fully capitalized format.

$sign = strtoupper(sha1($codes));

5. after the signature string is obtained, append it to the corresponding URL as the sign parameter to access the API normally.

$url= URL . '?appkey='.APPKEY.'&sign='.$sign.$queryString; $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);curl_setopt($curl, CURLOPT_ENCODING, 'UTF-8'); $data = json_decode(curl_exec($curl), true); curl_close($curl);


3.,Effect demonstration

Discount search

Merchant search

Group purchase search

After opening the link in group buying

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.