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.

62 lines
2.6 KiB

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden 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.

namespace LaneWeChat\Core;
/**
* 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');
}
}
namespace LaneWeChat\Core;
/**
* 这一行声明了类的文档注释,提供了类的基本信息。
* 创建者lixuan-it@360.cn
* 用户名lane
* 日期15/4/29
* 时间上午10:51
* 邮箱lixuan868686@163.com
* 网站http://www.lanecn.com
*/
class Auth {
/**
* 获取微信服务器IP列表
* 这个方法用于获取微信服务器的IP地址列表。
*/
public static function getWeChatIPList(){
// 获取ACCESS_TOKEN
$accessToken = AccessToken::getAccessToken(); // 调用AccessToken类中的getAccessToken方法来获取微信的ACCESS_TOKEN。
// 构造请求微信服务器IP列表的URL并将ACCESS_TOKEN拼接在URL中。
$url = 'https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=' . $accessToken;
// 使用Curl类中的callWebServer方法发起一个GET请求到构造好的URL获取微信服务器的IP列表。
return Curl::callWebServer($url, '', 'GET');
}
}