三合一好友码

之前文章有写过三合一收款码,看到有人发好友码了,于是随手写了一下(好几天没发文章了水一下),原理和三合一收款码一样的,都是判断浏览器UA标识进行跳转.直接上代码吧

<?php
$qq="http://qm.qq.com/cgi-bin/qm/qr?k=sDXrqEhzrgw1pW2WmXXbnlov_RYEn8oT";
$zfb="https://qr.alipay.com/a7x04237kp9mzxrpezdr81a";
$wx="https://u.wechat.com/EJNs8aFYFn9wdaZMYeu7uAA";
$qrcodeApi="//api.oioweb.cn/qr/?m=5&e=L&p=10&url=";
$thisurl="https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
if (preg_match('/Alipay/i',$_SERVER['HTTP_USER_AGENT' ])) {
  header("Location: $zfb"); 
  exit;
} elseif (preg_match('/QQ\//i',$_SERVER['HTTP_USER_AGENT' ])) {
  header("Location: $qq"); 
  exit;
}
?>
<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <script src="https://qrpay.oioweb.cn/js/qqapi.js?_bid=152"></script>
    <title><?php if (preg_match('/MicroMessenger\//i',$_SERVER['HTTP_USER_AGENT' ])) {
            echo "微信好友";
        } else {
            echo "好友码";
        }
          ?></title>
    <style>
        body, html {
        height: 100%;
        margin: 0;
        font-size: 16px;
        }
        body{
            display: block;
        }
        div{
            display: block;
        }
        #color{
            background-color: rgb(84, 188, 110);
        }
        #code{
            width: 100%;
        }
        #ui-head{
            background-color: #fff;
            padding: 10px 0;
            display: -webkit-box;
            width: 100%;
            -webkit-box-align: center;
            -webkit-box-pack: center;
        }
        #logo{
            width: 55px;
            height: 55px;
            background: url(<?php if (preg_match('/MicroMessenger\//i',$_SERVER['HTTP_USER_AGENT' ])) {
            echo "https://ww1.sinaimg.cn/large/006Fzy5igy1g1r01idi9wj308c08cq31.jpg";
        } else {
            echo "https://ww1.sinaimg.cn/large/006Fzy5igy1g1r0sy9kmkj30lq0ln758.jpg";
        }
          ?>);
            background-size: 100% 100%;
            margin: 5px;
            border-radius: 30px;
        }
        h2{
            font-weight: 500;
        }
        #ui-box{
            -webkit-box-flex: 1;
            display: -webkit-box;
            width: 100%;
            -webkit-box-align: center;
        }
        #ui-tips{
            background-color: #fff;
            color: #46a638;
            font-size: 18px;
            text-align: center;
            padding: 5px 0;
            margin: 40px auto;
            width: 240px;
            border-radius: 20px;
        }
        #ui-qrcode{
            background-color: #fff;
            border-radius: 15px;
            width: 230px;
            height: 230px;
            margin: 0 auto;
            text-align: center;
        }
        #qr-url{
            width: 210px;
            height: 210px;
            margin-top: 10px;
        }
    </style>
</head>
<body id="color">
    <div id="code">
        <div id="ui-head">
            <div id="logo">
            </div>
            <h2><?php if (preg_match('/MicroMessenger\//i',$_SERVER['HTTP_USER_AGENT' ])) {
            echo "微信好友";
        } else {
            echo "好友码";
        }
          ?></h2>
        </div>
    </div>
    <div id="ui-box">
        <div id="ui-tips">
            <?php if (preg_match('/MicroMessenger\//i',$_SERVER['HTTP_USER_AGENT' ])) {
            echo "请长按二维码添加好友";
        } else {
            echo "请打开APP扫码";
        }
          ?>
        </div>
    </div>
    <div id="ui-qrcode">
        <img id="qr-url" src="<?php if (preg_match('/MicroMessenger\//i',$_SERVER['HTTP_USER_AGENT' ])) {__    ___echo" qrcodeApi="true" wx="true" else="true" echo="true" thisurl="true">"/>
    </div>
</body>
</html> 

自己用的话只修改:

$qq="http://qm.qq.com/cgi-bin/qm/qr?k=sDXrqEhzrgw1pW2WmXXbnlov_RYEn8oT";
$zfb="https://qr.alipay.com/a7x04237kp9mzxrpezdr81a";
$wx="https://u.wechat.com/EJNs8aFYFn9wdaZMYeu7uAA"; 

信息为自己的就行了
由于博客编辑器的原因 部分代码发不出来,
下载地址:https://share.weiyun.com/5p56uo8

欢迎留言