如何调用微信内置浏览器打开指定链接

qq_38525755 2017-09-07 10:14:23
目前对接一个第三方支付,第三方支付只能生成一个链接,而这个链接必须在微信浏览器里面打开才能自动跳转到微信支付,所以现在的问题是,我如何唤起微信并调用微信浏览器跳转到这个链接让用户进行支付。

求各位大神支招,谢谢了!
...全文
2271 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
tu_ot 2018-10-06
  • 打赏
  • 举报
回复

<?php
// 统一调用微信白名单接口:https://wq.jd.com/mjgj/link/GetOpenLink?callback=getOpenLink&rurl=https://dc2.jd.com/auto.php?service=transfer&type=pms&to=(这里是拼接自己的内容地址比如http://mjbbs.jd.com/data/attachment/forum/201806/08/173526pb2zpjzzooo2ofze.jpg)
if($_GET['t']){
// include("admin/config.php");
// include("admin/function.php");
$code = $_GET['t'];
$info = query ( "jump_logs", "where code='" . $code . "'" );
if($info['code'] == ''){
    echo '跳转失败';
    exit(0);
}
if($info['state'] == '1'){
if($info['count'] >= $info['num']){
    echo '跳转失败';
    exit(0);
}
$time = strtotime($info['time']);
    if(time() > $time){
        echo '跳转失败';
        exit;
    }
}else{
    echo '跳转失败';
    exit;
}
if($info['www_url'] == ''){
    echo '请先配置落地页';
    exit;
}else{
    $w_url_code = $info['rl'];
}
?>

<?php
function get_ticket($code){
    //初始化
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts
    $headers = array();
    $headers[] = 'User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 11_1_2 like Mac OS X; zh-CN) AppleWebKit/537.51.1 (KHTML, like Gecko) Mobile/15B202 UCBrowser/11.7.7.1031 Mobile  AliApp(TUnionSDK/0.1.20)';
    $headers[] = 'Referer: https://m.mall.qq.com/release/?busid=mxd2&ADTAG=jcp.h5.index.dis';
    $headers[] = 'Content-Type:application/x-www-form-urlencoded; charset=UTF-8';
 
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    $content = curl_exec($ch);
    curl_close($ch);
    //$arr = json_decode($content,1);
    //if($arr['success'] == '1'){
    //    $shotCode = $arr['shotCode'];
    //}else{
    //    $shotCode = '';
    //}
    //preg_match('/openlink\":\"(.*?)\"}/',$content,$result);
    //$url = $result[1];
     
    preg_match('/href=\"(.*?)#wechat/',$content,$result);
    $url = $result[1];
    return $url;
}
    $time = time()-$info['ticket_time'];
    $minute=floor($time/60);
    query_update ( "jump_logs", "count=count+1". " where code='" . $code . "'" );
    if($minute >= 59){
        //如果超过1小时,更新ticket
        $url = get_ticket($w_url_code);
        if($url){
        query_update ( "jump_logs", "ticket_time='".time()."', ticket='" . $url . "' where code='" . $code . "'" );
        $ticket_url = $url.'#';
        if(strpos($_SERVER['HTTP_USER_AGENT'], 'baiduboxapp')||strpos($_SERVER['HTTP_USER_AGENT'], 'baiduboxapp')){//安卓百度手机APP
            echo '<script>window.location.href = "bdbox://utils?action=sendIntent&minver=7.4¶ms=%7b%22intent%22%3a%22'.$url.'%23wechat_redirect%23wechat_redirect%23Intent%3bend%22%7d";</script>';
            }else{
                echo '<script>window.location.href = "'.$ticket_url.'";</script>';
            }
        }
    }else{
        $ticket_url = $info['ticket'].'#';
        if(strpos($_SERVER['HTTP_USER_AGENT'], 'baiduboxapp')||strpos($_SERVER['HTTP_USER_AGENT'], 'baiduboxapp')){//安卓百度手机APP
            echo '<script>window.location.href = "bdbox://utils?action=sendIntent&minver=7.4¶ms=%7b%22intent%22%3a%22'.$info['ticket'].'%23wechat_redirect%23wechat_redirect%23Intent%3bend%22%7d";</script>';
            }else{
                echo '<script>window.location.href = "'.$ticket_url.'";</script>';
            }
    }
}
?>
<!--有不懂的地方联系我的Q:3220192183--> 
土豆欧尼酱 2017-10-20
  • 打赏
  • 举报
回复
官网有个微信web开发工具,可以解决你的问题

3,143

社区成员

发帖
与我相关
我的任务
社区描述
微信开发即微信公众平台开发,将企业信息、服务、活动等内容通过微信网页的方式进行表现,通过二次开发可以将公众账号由一个媒体型营销工具转化成提供服务的产品。
社区管理员
  • 微信开发
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧