You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace LaneWeChat\Core; // 定义命名空间为 LaneWeChat\Core表示该类属于 LaneWeChat 模块的核心部分
/**
* Auth类用于与微信公众平台的相关操作进行交互。
*
* 该类包含了获取微信服务器IP列表的方法常用于验证服务器是否能够访问微信API。
*
* 创建者lixuan-it@360.cn
* 用户名lane
* 日期15/4/29
* 时间上午10:51
* 邮箱lixuan868686@163.com
* 网站http://www.lanecn.com
*/
class Auth {
/**
* 获取微信服务器IP列表
*
* 该方法用于请求微信公众平台API获取微信服务器的IP地址列表。
* 此IP列表通常用于设置服务器白名单确保微信服务器能正常与当前服务器进行通信。
*
* @return mixed 返回微信服务器IP列表的响应数据
*/
public static function getWeChatIPList() {
// 获取ACCESS_TOKEN调用AccessToken类中的getAccessToken方法来获取微信的ACCESS_TOKEN。
// ACCESS_TOKEN是调用微信API接口的必需参数。
$accessToken = AccessToken::getAccessToken();
// 构造请求微信服务器IP列表的URL拼接上获取到的ACCESS_TOKEN。
// 通过URL请求的方式调用微信API获取服务器IP地址列表。
$url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=' . $accessToken;
// 使用Curl类中的callWebServer方法发起一个GET请求到构造好的URL。
// callWebServer方法用于向微信API发起请求并获取响应数据。
// 返回的结果是一个包含微信服务器IP地址的列表通常是JSON格式的。
return Curl::callWebServer($url, '', 'GET');
}
}