php crash _day4

First, the micro-channel public platform overview

1, the history of the development of micro-channel

1) January 21, 2011, Tencent launched micro-channel applications. (Zhang Xiaolong)

2) August 20, 2012, Tencent launched a micro letter public platform functions, open interfaces to third parties in November the same year

3) November 2013 registered users exceeded 600 million, it is the largest mobile instant messaging software user community in Asia.

4) As of the second quarter of 2016, micro-channel has covered more than 94 percent of the Chinese smartphone users reached 806 million monthly active users covering more than 200 countries, more than 20 languages.

2, micro-channel public platform

Tencent micro-channel public platform to allow users to apply for and manage micro-channel public accounts and the launch of a Web platform, micro-channel public account management operations carried out under this platform. Carried out all users in Tencent micro letter public by providing a single platform

It used to manage the micro-channel public number

Related operations:

Platform Address: https://mp.weixin.qq.com/

3, with the difference between the micro-channel micro-channel public platform

APP micro-channel is based on the relationship between individual personal point of use you send a message to your classmates

Micro-channel public platform is based on publicly-many relationships can be used to focus on its push users to provide news and information and related services functions.

4, micro-channel public platform two operating modes (Key)

  • Edit mode

The use of micro-channel public number increased public micro-channel unified management platform to operate. All functions are already written, can be used directly. Only need to edit the content information. Programming is not suitable for people to use.

  • Developer mode

Micro-channel public platform provides a way to access the server, with the ability to develop the operator, can be customized development.

Note: micro-channel public platform to manage, edit mode and developer mode are mutually exclusive, that can only use one of them.

5, presentation micro-channel public platform editing mode

In edit mode you can micro-channel public platform, user-related operations management and message reply.

No need to write code, you can achieve some basic functions.

6, who is using micro-channel public platform

① star Chen Kun personal publicity

② enterprises cultural propaganda

③ mall site jd Suning Tesco

④ Education Group to learn English New Oriental Education Group Public programmers dark horse No.

Push messages to achieve consultation services and functions

Second, the micro-channel developer mode

1. What is the developer mode

Micro-channel public platform to improve the way the third-party server access.

Third-party server can call micro-channel public platform to improve the way API interface, docking to achieve some functions and data.

Third-party servers: operators operating this number of public servers

2, micro-channel developer mode schematics

① programmers dark horse concern the public through the micro-letter APP No.

② Send "Get PHP latest free video course"

③ micro-channel public platform no information

④ micro-channel public platform sends a request to a third-party server, query data, and then return to the micro-channel APP

3, before the development of preparation

Before development requires attention to the following things:

  • It has a micro-channel public account

    http://kf.qq.com/faq/120911VrYVrA151009eIrYvy.html

  • Has a public network can access the server

    1> real physical servers tens of thousands of RMB

    2> cloud server can rent a year or press time, according to traffic

    aliyun Tencent cloud Baidu Cloud

    3> BAE cloud engine Baidu Sina SAE

    4> manner to the network through the network server, through technical means, mapped to the external network to access the public network

    Peanut shells NATAPP

4, NATAPP Software Registration

URL: https://natapp.cn/

Note: you can test by using free, but at present the domestic legal reasons, the need for real-name authentication.

After the free purchase is successful, as shown below:

After authtoken will use this configuration.

5, software configuration NATAPP

  • A system according to the number of bits, choose to install the corresponding software

  • Extracting the corresponding file compression package, and and config.ini configuration file, into a software catalog

    Software run directory can not have Chinese or spaces

  • Config.ini configuration

  • Use cmd command line to start natapp software

Now outside the network can access the public network, local network server of the domain name above

Note: This command line window can not be closed, if closed, will not be able to out-of-network with access to the domain name.

6, access to third-party servers

In order to make micro-channel public platform, third-party server for this operation to find the corresponding public account.

Third-party server, you need to access configuration.

Reference micro-channel public platform document:

https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421135319

  • To obtain access to documents
  • Copy the files inside, into the WWW directory, change the name to api.php
  • Turn on developer mode in the micro-channel public platform, and configure server information

See the top of the page is submitted successfully, verify that it is successful, the server access success.

7, turn on automatic reply function

Modify the code calls the message management method

Reply View results

Three, six micro-channel interfaces

1 Introduction

Documents Address

The type of user data to be transmitted micro-channel public number

Text, images, voice, video, small video, address position, links

2, the user determines the type of data transmitted

Receiving a user's information, micro-channel public platform pushed to a third-party server, the XML document is sent way.

xml: can expand Markup Language (HTML and type), you can customize the label. Data used for identifying

① having a pair of root tag

② tags are closed in pairs

Write an example: a person store information

xiaoming

18

PHP

You can receive various types of messages XML template

For determining what type of message received by the XML tags in the MsgType

Text MsgType = text

Pictures MsgType = image

Voice MsgType = voice

Video MsgType = video

Small video MsgType = shortvideo

Location MsgType = location

Link MsgType = link

3, using the file is received and return information

  • Adding to get the type of reception information

Fourth, the micro-channel of the three major interfaces replies

1, the interface text reply

2, Music Interface reply

3 Graphic Interface reply

Fifth, the micro-channel Turing robot

1, customer service robot

See some of the micro-channel public number, with automatic reply function, and is more intelligent.

You can deal with some corresponding questions to answer, save labor.

2, Turing robot

Belonging to third parties robot can be achieved chat, check the weather and so on function.

Official Website: http://www.tuling123.com/

http://www.turingos.cn/tiyan_duihua.html

3, call the Turing interface

http://www.tuling123.com/help/h_cent_webapi.jhtml?nav=doc

  • Sign up for an account

  • Log management platform, to create a robot to obtain key

  • Already created robots to view the information

    Good API access applications address and APIKEY

    Note that the data pay attention to two points:

    ①POST transmission

    Encapsulating the curl library

    ② JSON format data transmission is necessary to provide a transmission header Header length

    json_encode array by array json data transfer format.

    curl_setopt($ch, CURLOPT_HTTPHEADER, array(

    ​ 'Content-Type:application/json',

    ​ 'Content-Length:'.strlen($data))

    );

    Use curl function package, the API request is transmitted, corresponding data is acquired

    References tuling.php

Guess you like

Origin www.cnblogs.com/jiaxiaozia/p/12323508.html