相信很多老铁都有这么一个需求,就是如何在外部实现点击一个去微信加好友的功能,因为这样真的可以大大的提高转化率,现在我分享下我自己的成果,我有三套方案,后续再一套一套的分享给大家,如果不懂的地方,可以找我的,我会帮你解决难题。
<?php
include("data/config.php");
$id = $_GET['id'];
$sql = "select * from wx_list where id='".$id."'";
$rs = mysql_fetch_array(mysql_query($sql));
$s_time = strtotime (date('Y-m-d'));
$e_time = strtotime ($rs['e_time']);
$r_time = ceil(($e_time - $s_time));
if($r_time <= 0){
echo '
跳转失败
微信跳转联系QQ:1142878091
';
exit;
}
$count = $rs['count'] + 1;
mysql_query($sql = "update wx_list set count='".$count."' where id='".$id."'");
function get_ticket($code){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$contents = curl_exec($ch);
preg_match('/ticket=(.*?)\"/',$contents,$result);
$content = $result[1];
return $content;
}
if(time() - $rs['uptime'] >= 1800) {
$www_url = get_ticket($rs['www_url']);
mysql_query($sql = "update wx_list set ticket='".$www_url."',uptime='".time()."' where id='".$id."'");
} else {
$www_url = $rs['ticket'];
}
?>
正在跳转中
微信跳转免费代码联系QQ:1142878091
<a href="weixin://dl/business/?ticket=" style="width: 90%;background: #1AAD19;text-align: center;color: #fff;margin: 0 auto;box-sizing: border-box;font-size: 18px;line-height: 2.55555556;border-radius: 5px;display: block;text-decoration: none;">再次跳转
window.location.href="weixin://dl/business/?ticket=";
下面是效果图,看是不是最终的结果,数据库文件发不了。需要再来找我吧。