WeChat public platform interface development example-PHP source code

Source: Internet
Author: User
This article mainly introduces the example of getting started with public platform interface development. It provides a simple and thorough analysis of the skills and methods for public platform interface development and provides some reference value, for more information about how to develop public platform interfaces, see this article, it has some reference value. For more information, see

This example describes how to get started with public platform interface development. Share it with you for your reference. The details are as follows:

Interface development on the public platform is a commonly used function. many people will learn about some simple development applications on the public platform. here is an example of getting started.

During this time, I am busy with the public account platform. now it is coming to an end. so I would like to say a word or two about how to use the interfaces of the development platform.

The development of the platform is not as difficult as you think. it is nothing more than data access and processing. data access, such as message boards, data storage, we use a form to submit data to the database for storage. We use a query statement to obtain data from the database and access the data, the public platform opens a variety of interfaces to meet different types of data access, so that we can indirectly access data to the public platform database through interfaces.

First, let's look at an interface for creating a menu:

Https://www.php1.cn/

This interface currently requires the service number to have permissions, but if you do not have a service number, you can apply for a Test number for one year. The ACCESS_TOKEN in this interface is a public number, the AppID and AppSecret of the service number or test number are obtained. each interface that can access data requires ACCESS_TOKEN.

The interface is available, but how can we use it to access data on the public platform? You can use the following function to call it. the code is as follows:

function https_request($url,$data = null){     $curl = curl_init();     curl_setopt($curl, CURLOPT_URL, $url);     curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);     curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE);     if (!emptyempty($data)){         curl_setopt($curl, CURLOPT_POST, 1);         curl_setopt($curl, CURLOPT_POSTFIELDS, $data);     }    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);     $output = curl_exec($curl);     curl_close($curl);     return $output; }

Note:This is a php function, $ url is the public number interface, $ data is a json format data.

Usage:

Data retrieval:

Https_request ($ url );

Save data:

Https_request ($ url, $ data );

Summary:When retrieving data, the https_request function returns data in json format. before storing data, if $ data is not in json format, it must be converted to json data.

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.