PHP version of micro-data Statistics Interface Usage example detailed

Source: Internet
Author: User
This article mainly introduces the PHP version of the data statistics interface usage, combined with the example form analysis of PHP data statistics interface functions and related use skills, the need for friends can refer to the following

The example in this paper describes the PHP version of Data statistics interface usage. Share to everyone for your reference, as follows:

PHP version of the data statistics interface is actually very useful in the previous version has not yet this feature is added to the later version, the following is a PHP version of the data statistics interface example:

A new data analysis interface portal was released on January 6:

Please note:

1, the interface side of the public number data in the database only stores the data after December 1, 2014, will not be queried before the date, even if it is found, is not credible dirty data;

2, the developer after the call interface to obtain data, save the data in their own database, that is, to speed up the next user access speed, but also reduce the unnecessary loss of side interface calls.

The user analysis data interface refers to the interface for obtaining user analysis data in the data statistics module of public platform, and the interface list is as follows (no user attribute data interface):

The maximum time span is the time range at which the maximum data can be fetched at an interface call, such as a maximum time span of 7, which is a one-off fetch of up to 7 days of data. The actual value of the Access_token can be obtained by "get Access_token".

Interface Invocation Request Description

The User analysis data interface (including all interfaces in the interface list) needs to be called to the appropriate interface post the following sample packet:

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

Call parameter Description:

A cursory look at the next, temporary or beta stage, but because it is a new interface, so to improve the next site to use the Advanced interface class. Modify the following:

Add a new interface constant 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 access token so it is the same as the previous JSON, but to add datacube judgment in judgment (note: note has been explained):

Public Function call ($api _name, $params = Array (), $type = Self::get, $api _type = self::api_type_cgi) {//Add Datacube, use        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) {//plus multiple or access_token if ($type = = Self::json | | $api _type = SELF::API_TYPE_DA TA) {$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 mode in the call document is a Getinterfacesummary interface debug (Note: Is the post mode to the interface):

if (Isset ($ARGC) && $argc >= 1 && $argv [0] = = FILE) {  $client = new Wechatjson (Array (    WECHATJSO n::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 result of the operation, although the API is not authorized (after all, the conditional partner has the information, the public number of it):

PostScript, and then do a Linux task to let backstage himself every other time (a week or 30 days) because the data statistics interface there are 7 days, there are 30 days. This execution takes the data and then writes into the library table, generates the graph report, saves oneself the log some official already gave you the log statistic!

Related Article

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.