当前位置:网站首页>检测微信显示无效头像图片链接
检测微信显示无效头像图片链接
2022-08-03 05:26:00 【dd00bb】
class testModule
{
public function index()
{
$avatar_url = "https://thirdwx.qlogo.cn/mmopen/fPUctVSBSHt2AZPq6ibHz8cJQyapI7Xzo8quXictzOhLB1C9tz0wFWo4sia0baktdR9cgArGkZN8RtyxZAoZQWwicv3Oia5RKFQSw/132";
// 检测头像链接是否是https或http
if (filter_var($avatar_url , FILTER_VALIDATE_URL) === false) {
echo "头像链接不正确"
return
}
// 发送网络请求
$res = $this->httpGet($avatar_url );
// 检测请求头中是否有'X-ErrNo',有代表无效头像
if(strstr($res, 'X-ErrNo')){
echo "无效的微信头像";
}
echo "有效微信头像"
return
}
/** 获取请求头信息 */
private function httpGet($sUrl)
{
$oCurl = curl_init();
// 设置请求头, 有时候需要,有时候不用,看请求网址是否有对应的要求
$header[] = "Content-type: application/x-www-form-urlencoded";
$user_agent = "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.146 Safari/537.36";
curl_setopt($oCurl, CURLOPT_URL, $sUrl);
curl_setopt($oCurl, CURLOPT_HTTPHEADER, $header);
// 返回 response_header, 该选项非常重要,如果不为 true, 只会获得响应的正文
curl_setopt($oCurl, CURLOPT_HEADER, true);
// 是否不需要响应的正文,为了节省带宽及时间,在只需要响应头的情况下可以不要正文
curl_setopt($oCurl, CURLOPT_NOBODY, true);
// 使用上面定义的 ua
curl_setopt($oCurl, CURLOPT_USERAGENT, $user_agent);
curl_setopt($oCurl, CURLOPT_RETURNTRANSFER, 1);
// 不用 POST 方式请求, 意思就是通过 GET 请求
curl_setopt($oCurl, CURLOPT_POST, false);
$sContent = curl_exec($oCurl);
// 获得响应结果里的:头大小
$headerSize = curl_getinfo($oCurl, CURLINFO_HEADER_SIZE);
// 根据头大小去获取头信息内容
$header = substr($sContent, 0, $headerSize);
curl_close($oCurl);
return $header;
}
}
边栏推荐
猜你喜欢
随机推荐
MCU接收串口字符型数据转换成数据型数据
剑指 Offer II 001. 整数除法
classpath:与classpath*的比较
Makefile.am:24: error: Libtool library used but ‘LIBTOOL‘ is undefined
SolidWorks 操作视频 | 流体分析结果演示
What is parametric design, let's understand it through practical operation?| SOLIDWORKS How-To Videos
ZEMAX | How to rotate any element around any point in space
内网渗透之PPT票据传递攻击(Pass the Ticket)
一文看懂常见域名后缀的含义
NIO知识汇总 收藏这一篇就够了!!!
double型数据转字符串后通过MCU串口发送
cobalt strike 的基础使用
ue4学习日记4(植被,光照,光束遮挡,天空球)
【七夕特效】 -- 满屏爱心
数组与字符串11-反转字符串
数组与字符串9-翻转字符串里的单词
数组与字符串15-最大连续1的个数
VS2022 encapsulation under Windows dynamic library and dynamic library calls
window下VS2022封装动态库以及调用动态库
大学毕业后,零基础想转行成为一名3D建模师,现在该做什么?









