Image and text details: WeChat public platform development WeChat server IP interface instance (with code)

Source: Internet
Author: User
This article mainly introduces server IP interface instances in public platform development, which has good reference value. Next let's take a look at it with a small Editor. This article mainly introduces the public platform development server IP interface instance (with code), which has good reference value. Let's take a look at it with the small editor.

After learning how to obtain and apply access_token, you can use access_token to call interfaces of other public platforms to deepen your understanding and usage.

1. obtain the server IP address instance

(1) interface introduction

If the public account is based on security and other considerations, you need to know the server IP address list for restrictions, you can obtain the server IP address list or IP address segment information through this interface.

(2) instance call

Interface Description

Http request method: GET

Interface call address:

Api.weixin.qq.com/cgi-bin/getcallbackip? Access_token = ACCESS_TOKEN

The request parameters are described in the following table:


Parameters

Required?

Description

Access_token

Yes

Access_token of the public account

Return description:

Normally, a JSON data packet is returned to the public account ,:

Parameters

Description

Ip_list

Server IP address list

Code:

 $ Value) {echo $ value ."
"; // Print the IP set in a circular manner}?>

Code parsing:

Require ('Wei _ function. php'); contains wei_function.php

Use the getdata () function to replace the value of $ ipurl with the value of access_token after obtaining the access_token;

$ Iparr = (array) json_decode (getdata ($ ipurl); get $ ipurl data through the getdata () function, and then get $ iparr after processing through the json_decode function, the variable value is a two-dimensional array ,;

What we need is [ip_list] in the array. Therefore, we extract the array set of [ip_list] separately and use foreach to loop through each server IP address,

Code:

Foreach ($ iparr ['IP _ list'] as $ key => $ value) {echo $ value ."
"; // Print the IP set in a loop}


Run the program to call the interface result ,.

The above is a detailed description of the public platform development server IP interface instance (with code) details, please pay attention to other articles related to php Chinese network!

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.