当前位置:网站首页>检测微信显示无效头像图片链接
检测微信显示无效头像图片链接
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;
}
}
边栏推荐
- 【七夕特效】 -- 满屏爱心
- 【测试基础】bug分级、测试流程、ISO9126质量模型
- How the world's leading medical technology company maximizes design productivity | SOLIDWORKS Product Exploration
- 域名怎么管理,域名管理注意事项有哪些?
- 零基础小白想往游戏建模方向发展,3D游戏建模好学嘛?
- POE交换机全方位解读(中)
- 快速的将结构体各成员清零
- 使用ZBrush制作恶魔模型
- 【面试】摸鱼快看:关于selenium/ui自动化的面试题
- 9. Please introduce the class loading process, what is the parent delegation model?
猜你喜欢
随机推荐
Automatic ticket issuance based on direct reduction of China Southern Airlines app
ZEMAX | 探索 OpticStudio中的序列模式
Makefile.am:24: error: Libtool library used but ‘LIBTOOL‘ is undefined
二分查找2 - x的平方根
二分查找4 - 搜索旋转排序数组
2021-03-22
五、int和Integer有什么区别?
SQLMAP介绍及使用
2-php学习笔记之控制语句,函数
SSL证书过期后怎么办?
ZEMAX | 在 OpticStudio 中使用自由曲面进行设计
Practice of MySql's Sql statement (try how many you can write)
Phase Vocoder的补充完善,Matlab音频变速不变调、变调不变速
借助ginput函数在figure窗口实时读取、展示多条曲线的坐标值
ZEMAX | 如何创建复杂的非序列物体
电容器和电池有什么不同?
servlet学习(七)ServletContext
MySql的Sql语句的练习(试试你能写出来几道呢)
3D游戏建模师在国内的真实现状,想转行,先来看看!
classpath:与classpath*的比较









