Generating Scheduled Report

Last updated: 2021-03-19 15:15:22

    Overview

    This document uses SCF, MTA, and WeCom bot to perform scheduled tasks such as report content collection and data display.

    Directions

    Creating function

    1. Log in to the SCF console and select Function Service on the left sidebar.

    2. At the top of the Function Service page, select the Beijing region and click Create to enter the function creating page and configure the function as shown below:

      • Creation method: select Template.
      • Fuzzy search: enter "TimerReport" and search.
        Click Learn More in the template to view relevant information in the Template Details pop-up window, which can be downloaded.
    3. Click Next. The function name is automatically generated by default and can be modified as needed.

    4. In the Trigger Configurations section, select Automatic creation, and a scheduled trigger that will run on the hour will be created by default as shown below:

      Note:

      • If you need to adjust the trigger configuration according to your needs, please select Custom.
      • To create a scheduled trigger after the test is successful, please select Create Later.
    5. Click Complete.

    Testing function

    1. At the bottom of the function code page, click Test to view the execution log of the function and go to the WeCom group for confirmation.
    2. After the test is passed, you can configure the scheduled trigger in the Trigger Method tab according to the actual situation. To modify the configuration, please see Modifying function template.

    Relevant Operations

    Modifying function template

    The current template function only can pull reports from MTA sites. For more information, please see MTA Data API Description.
    Add the following code to modify the MTA parameters:

    $app_id ="xxxxxx"; // MTA APPID 
    $secret_key = 'xxxxx'; // MTA SECRET KEY

    Run the following command to access the WeCom bot. For more information, please see here.

      CURLOPT_URL => "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=xxxxx", // WeCom bot API