PHP version of micro-data statistical interface usage example _php tips

Source: Internet
Author: User

This article describes the PHP version of the micro-data statistics interface usage. Share to everyone for your reference, specific as follows:

PHP version of the micro-data interface is actually very useful in the previous version has not yet this feature is added to the later version of the following to see a PHP version of the micro-data Statistics Interface Example:

On January 6, the micro-letter released a new data analysis interface Portal:

Please note:

1, the interface side of the public Number data database only stores the data after December 1, 2014, will not be queried before the date, even if there is found, but also is not credible dirty data;

2, developers in the call interface to obtain data, the data stored in their own database, that is, to speed up the next user access speed, but also reduce the micro-trust interface calls unnecessary loss.

The user analysis data interface refers to the interface used for obtaining the user analysis data in the official website Data Statistic module of the public platform, and the concrete interface list is as follows (no user attribute data interface):

The maximum time span refers to the maximum amount of time that can be obtained when an interface is invoked, such as a maximum time span of 7, which refers to a maximum of 7 days of data. The actual value of the Access_token can be obtained by "get Access_token".

Interface Call Request Description

The user profiling data interface (including all interfaces in the interface list) requires the following sample packet to be called to the appropriate interface address:

{
  "begin_date": "2014-12-02",
  "end_date": "2014-12-07"
}

Call parameter Description:

A cursory look, temporarily or in the beta phase, but because it is a new interface, so to improve the site used in the micro-letter advanced Interface classes. Modified as follows:

Add new interface constants to the class:

Api_data_cube_url = ' Https://api.weixin.qq.com/datacube ',
api_type_data = ' Datacube '

Modify the call method: Because it requires the URL parameter to be just the access token so it is the same as the previous JSON, but add Datacube's judgment to the Judgment (note: The note has been explained):

Public Function call ($api _name, $params = Array (), $type = Self::get, $api _type = self::api_type_cgi) {//Join Datacube
        , switch to Group interface URL switch (true) {case $api _type = = Self::api_type_pay: $url = self::P ay_url. $api _name;
      Break
        Case $api _type = = Self::api_type_data: $url = self::api_data_cube_url. $api _name;
      Break
    Default: $url = Self::api_url_prefix. $api _name;
      } if (In_array ($api _name, Self::$_no_need_token_apis)) {$res = $this->request ($url, $params, $type);
      if ($res) {return $res;
    }} $this->_access_token = $this->getaccesstoken (); if ($this->_access_token) {//+ multiple or judgment band Access_token if ($type = = Self::json | | $api _type = = Self::api_type_ DATA) {$url = $url. '?
      Access_token= '. $this->_access_token;
      else {$params [' access_token '] = $this->_access_token;
      $res = $this->request ($url, $params, $type); If ($res)
      {return $res;
return false;

 }

The last CLI method is to debug a getinterfacesummary interface in the call document (note: Post way to the interface):

if (Isset ($ARGC) && $argc >= 1 && $argv [0] = = __file__) {
  $client = new Wechatjson (Array (
    Wecha tjson::app_id => ' wx78sfsd023744d51 ',
    wechatjson::app_secret => ' 9ba3476db1fsfsff512esf2f630fb9 ',
  ) ;
  $res = $client->call ('/getinterfacesummary ', Array (
    ' begin_date ' => ' 2014-12-01 ', ' end_date ' => ')
    2014-12-31 '
  ), Wechatjson::P Ost, Wechatjson::api_type_data);
  if (! $res) {
    var_dump ($client->_error);
  Var_dump ($res);


The results of the operation, although the API is not authorized (after all, there are qualified partners have data, the public number of the bar):

PostScript, later do a Linux task to let the background of their own every time (a week or 30 days) because the data statistics interface are 7 days, some 30 days. This is done by taking the data and then writing it into the library table, generating the chart report, and saving yourself log some officials have given you log stats!

For more information on PHP related content readers can view the site topics: "PHP micro-credit Development Skills summary", "PHP coding and transcoding Operation skills Summary", "PHP Network Programming Skills Summary", "PHP basic Grammar Introductory Course", "PHP string (String) Usage Summary", "php+ MySQL Database operations Introduction tutorial and PHP Common database operation Skills Summary

I hope this article will help you with the PHP program design.

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.