欢迎来到好人卡资源网,专注网络技术资源收集,我们不仅是网络资源的搬运工,也生产原创资源。寻找资源请留言

【PHP】php源码自动识别设备跳转指定QQ聊天窗口代码,苹果安卓电脑都可以成功

网站源码 sky995 3个月前 (08-26) 88次浏览 0个评论

前言

你还在用http://wpa.qq.com/msgrd?v=3&uin=1845440070&site=qq&menu=yes这种url进行qq会话窗口跳转吗?如果是那就老了,这个url不适配苹果手机,苹果手机浏览器访问这个url会跳转到苹果的应用商店!

新方法

<code class=" language-php"><span class="token php language-php"><span class="token delimiter important"><span class="pun"><?</span><span class="pln">php</span></span>
<span class="token function"><span class="pln">header</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token single-quoted-string string"><span class="str">'Content-Type:application/json; charset=utf-8'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token variable"><span class="pln">$agent</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token function"><span class="pln">strtolower</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$_SERVER</span></span><span class="token punctuation"><span class="pun">[</span></span><span class="token single-quoted-string string"><span class="str">'HTTP_USER_AGENT'</span></span><span class="token punctuation"><span class="pun">]</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token comment"><span class="com">//url 参数 ?qq=123456789</span></span>
<span class="token variable"><span class="pln">$qq</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token function"><span class="pln">isset</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$_GET</span></span><span class="token punctuation"><span class="pun">[</span></span><span class="token single-quoted-string string"><span class="str">'qq'</span></span><span class="token punctuation"><span class="pun">]</span></span><span class="token punctuation"><span class="pun">)</span></span> <span class="token operator"><span class="pun">?</span></span> <span class="token variable"><span class="pln">$_GET</span></span><span class="token punctuation"><span class="pun">[</span></span><span class="token single-quoted-string string"><span class="str">'qq'</span></span><span class="token punctuation"><span class="pun">]</span></span> <span class="token punctuation"><span class="pun">:</span></span> <span class="token double-quoted-string string"><span class="str">""</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token keyword"><span class="kwd">if</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token function"><span class="pln">empty</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$qq</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">{</span></span>
  <span class="token keyword"><span class="pln">echo</span></span> <span class="token function"><span class="pln">json_encode</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token keyword"><span class="pln">array</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token single-quoted-string string"><span class="str">'code'</span></span><span class="token operator"><span class="pun">=</span></span><span class="token operator"><span class="pun">></span></span><span class="token number"><span class="lit">201</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="token single-quoted-string string"><span class="str">'msg'</span></span><span class="token operator"><span class="pun">=</span></span><span class="token operator"><span class="pun">></span></span><span class="token single-quoted-string string"><span class="str">'QQ不能为空'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="token number"><span class="lit">480</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span><span class="token keyword"><span class="pln">elseif</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token operator"><span class="pun">!</span></span><span class="token function"><span class="pln">preg_match</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token double-quoted-string string"><span class="str">"/^[1-9][0-9]{4,10}$/"</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="token variable"><span class="pln">$qq</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">{</span></span>
  <span class="token keyword"><span class="pln">echo</span></span> <span class="token function"><span class="pln">json_encode</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token keyword"><span class="pln">array</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token single-quoted-string string"><span class="str">'code'</span></span><span class="token operator"><span class="pun">=</span></span><span class="token operator"><span class="pun">></span></span><span class="token number"><span class="lit">202</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="token single-quoted-string string"><span class="str">'msg'</span></span><span class="token operator"><span class="pun">=</span></span><span class="token operator"><span class="pun">></span></span><span class="token single-quoted-string string"><span class="str">'QQ格式不正确'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="token number"><span class="lit">480</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span><span class="token keyword"><span class="pln">elseif</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token function"><span class="pln">strpos</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$agent</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="token single-quoted-string string"><span class="str">'windows nt'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">{</span></span>
  <span class="token variable"><span class="pln">$loca</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token double-quoted-string string"><span class="str">"tencent://ContactInfo/?subcmd=ViewInfo&puin=0&uin=</span><span class="token interpolation"><span class="token punctuation"><span class="str">{</span></span><span class="token variable"><span class="str">$qq</span></span><span class="token punctuation"><span class="str">}</span></span></span><span class="str">"</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span><span class="token keyword"><span class="pln">elseif</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token function"><span class="pln">strpos</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$agent</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="token single-quoted-string string"><span class="str">'iphone'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">{</span></span>
  <span class="token variable"><span class="pln">$loca</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token double-quoted-string string"><span class="str">"mqq://im/chat?chat_type=wpa&uin=</span><span class="token interpolation"><span class="token punctuation"><span class="str">{</span></span><span class="token variable"><span class="str">$qq</span></span><span class="token punctuation"><span class="str">}</span></span></span><span class="str">&version=1&src_type=web"</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span><span class="token keyword"><span class="pln">elseif</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token function"><span class="pln">strpos</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$agent</span></span><span class="token punctuation"><span class="pun">,</span></span><span class="token single-quoted-string string"><span class="str">'android'</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">{</span></span>
  <span class="token variable"><span class="pln">$loca</span></span> <span class="token operator"><span class="pun">=</span></span> <span class="token double-quoted-string string"><span class="str">"mqq://card/show_pslcard?src_type=internal&version=1&uin=</span><span class="token interpolation"><span class="token punctuation"><span class="str">{</span></span><span class="token variable"><span class="str">$qq</span></span><span class="token punctuation"><span class="str">}</span></span></span><span class="str">&card_type=person&source=sharecard"</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="token punctuation"><span class="pun">}</span></span>
<span class="token keyword"><span class="kwd">if</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token function"><span class="pln">empty</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token variable"><span class="pln">$loca</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token operator"><span class="pun">==</span></span><span class="token boolean"><span class="kwd">false</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">{</span></span>
<span class="token function"><span class="pln">header</span></span><span class="token punctuation"><span class="pun">(</span></span><span class="token double-quoted-string string"><span class="str">"Location:</span><span class="token interpolation"><span class="token variable"><span class="str">$loca</span></span></span><span class="str">"</span></span><span class="token punctuation"><span class="pun">)</span></span><span class="token punctuation"><span class="pun">;</span></span>
<span class="kwd">exit</span><span class="token punctuation"><span class="pun">;</span></span> 
<span class="token punctuation"><span class="pun">}</span></span>
<span class="token delimiter important"><span class="pun">?></span></span></span></code>
PHP

食用教程

新建一个php文件,命名为jumpQQ.php,将代码放进去,放到php网站运行目录任意地方,然后访问:域名(ip)/jumpQQ.php?qq=1845440070即可


好人卡资源网 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:【PHP】php源码自动识别设备跳转指定QQ聊天窗口代码,苹果安卓电脑都可以成功
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址