抖音私信卡片,解决了客户封号严重、引流效率低的痛点,所以从去年到现在,依然是热销品。
"抖音快手私信名片链接跳转"是2022年抖音快手引流最新技术,可以生成卡片链接,支持标题、描述、logo以及跳转落地页的完全自定义配置.
支持微信公众号和微信号复制唤起微信客户端app添加,同时也支持任意链接落地页跳转
提高粉丝引流转化率,关注转化率,引流转化率,安全绿色
私信卡片功能
1、跳转微信
用户点击卡片,自动跳转微信界面,显示好友和群聊二维码
2、跳转链接
用户点击卡片,自动跳转到指定链接,支持任意链接。
3、跳转小程序
用户点击卡片,自动跳转到小程序,支持任意路径。
主要代码展示:
<?php
namespace app\cx_dyfx\controller;
use think\facade\Db;
use think\facade\Request;
use think\facade\View;
use vitphp\admin\controller\BaseController;
/**
* @title 链接管理(www.lxh5068.com)
*/
class Url extends BaseController
{
/**
* @title 链接列表(www.lxh5068.com)
*/
public function index(){
$pid = input('pid');
$pageNum = 20;
$url = Db::name('cx_dyfx_url')->where('pid', $pid)->order('id desc')->paginate($pageNum);
$hdurl = Request::domain() .'/cx_dyfx/index/';
View::assign([
'url'=>$url,
'page'=>$url->render(),
'hdurl'=>$hdurl
]);
return View::fetch();
}
/**
* @title 编辑链接
*/
public function edit(){
$pid = input('pid');
$id = input('id');
$url = Db::name('cx_dyfx_url')->where(['pid'=>$pid,'id'=>$id])->find();
if($url){
$url['expire_time'] = $url['expire_time'] ? date("Y-m-d H:i:s", $url['expire_time']) : '';
}
//判断是否post提交
if(request()->isPost()){
$param = [
'name'=>input('name'),
'url'=>input('url'),
'title'=>input('title'),
'miaoshu'=>input('miaoshu'),
'img'=>input('img'),
'appid'=>input('appid'),
'appsecret'=>input('appsecret'),
'path'=>input('path'),
'is_expire' => input('is_expire'),
'expire_days' => input('expire_days'),
'expire_time' => strtotime(input('expire_time')),
'type'=>input('type'),
'state'=>'0',
'time'=>time(),
'pid'=>$pid
];
if($param['type']==3){
$param['title'] = input('title2');
$param['miaoshu'] = input('miaoshu2');
$param['img'] = input('img2');
$param['content'] = input('content');
$param['is_expire'] = input('is_expire2');
$param['expire_days'] = input('expire_days2');
$param['expire_time'] = strtotime(input('expire_time2'));
if($param['is_expire']!=3) unset($param['expire_time']);
if($param['is_expire']!=2) unset($param['expire_days']);
if($param['is_expire']==2){
if(!$param['expire_days']) $this->error('请填写正确的有效天数!');
if(($param['expire_days']%1!=0 || $param['expire_days']<=0)) $this->error('请填写正确的有效天数!!');
if($param['expire_days'] >= 365) $this->error('有效天数最长为365天!');
$path = [
'is_expire' => true,
'expire_type' => 1,
'expire_interval' => $param['expire_days']
];
}
if($param['is_expire']==3){
if(!$param['expire_time']) $this->error('请选择正确的有效时间!');
if($param['expire_time'] <= time()) $this->error('有效期最少要大于当下!');
if($param['expire_time'] - time() >= 86400 * 365) $this->error('有效期最长为1年!');
$path = [
'is_expire' => true,
'expire_type' => 0,
'expire_time' => $param['expire_time']
];
}
$path = $path ?? [];
$path['path'] = 'pages/webview/webview';
$path['query'] = 'url=https://'.$this->request->host().'/cx_dyfx/index/h5.html?id='.$id;
// $path = ['path' => 'pages/webview/webview', 'query' =>'url=https://'.$this->request->host().'/cx_dyfx/index/h5.html?id='.$id];
$wechatConfig = Db::name('cx_dyfx_weixin')->where('pid', '=', $pid)->find();
$config = [
'appsecret' => $wechatConfig['wxapp_appsecret'],
'appid' => $wechatConfig['wxapp_appid'],
];
$mini = new \WeMini\Qrcode($config);
try {
$wxapp = app_http_request("https://api.weixin.qq.com/wxa/generate_urllink?debug=1&access_token=" . $mini->getAccessToken(), $path, [], [], true);
} catch (\Exception $e) {
$this->error('微信配置有误:'.$e->getCode() . '-' . $e->getMessage());
}
$url = json_decode($wxapp, true);
if ($url["errcode"]=='0'){
$param['url'] = $url['url_link'];
} else {
$this->error('链接生成失败:'. $url['errcode'] . '--' . $url['errmsg']);
}
}
if($param['type']==1){
if($param['is_expire']!=3) unset($param['expire_time']);
if($param['is_expire']!=2) unset($param['expire_days']);
if($param['is_expire']==2){
if(!$param['expire_days']) $this->error('请填写正确的有效天数');
if(($param['expire_days']%1!=0 || $param['expire_days']<=0)) $this->error('请填写正确的有效天数!');
if($param['expire_days'] >= 365) $this->error('有效天数最长为365天');
$path = [
'is_expire' => true,
'expire_type' => 1,
'expire_interval' => $param['expire_days']
];
}
if($param['is_expire']==3){
if(!$param['expire_time']) $this->error('请选择正确的有效时间');
if($param['expire_time'] <= time()) $this->error('有效期最少要大于当下');
if($param['expire_time'] - time() >= 86400 * 365) $this->error('有效期最长为1年');
$path = [
'is_expire' => true,
'expire_type' => 0,
'expire_time' => $param['expire_time']
];
}
// 生成链接
$config = [
'appsecret' => $param['appsecret'],
'appid' => $param['appid'],
];
$mini = new \WeMini\Qrcode($config);
$pathArr = $param['path'] ? explode('?', $param['path']) : [];
if($pathArr){
$path['path'] = $pathArr[0];
$path['query'] = $pathArr[1] ?? '';
}
$path = $path ?? [];
try {
$wxapp = app_http_request("https://api.weixin.qq.com/wxa/generate_urllink?debug=1&access_token=" . $mini->getAccessToken(), $path, [], [], true);
} catch (\Exception $e) {
$this->error('微信配置有误:'.$e->getCode() . '-' . $e->getMessage());
}
$url = json_decode($wxapp, true);
if ($url["errcode"]=='0'){
$param['url'] = $url['url_link'];
} else {
$this->error('链接生成失败:'. $url['errcode'] . '--' . $url['errmsg']);
}
}
if ($id){
$res = Db::name('cx_dyfx_url')->where('id',$id)->update($param);
}else{
$param['create_time'] = time();
$res = $id = Db::name("cx_dyfx_url")->insertGetId($param);
if($param['type']==3){
$path = ['path' => 'pages/webview/webview', 'query' =>'url=https://'.$this->request->host().'/cx_dyfx/index/h5.html?id='.$id];
$wechatConfig = Db::name('cx_dyfx_weixin')->where('pid', '=', $pid)->find();
$config = [
'appsecret' => $wechatConfig['wxapp_appsecret'],
'appid' => $wechatConfig['wxapp_appid'],
];
$mini = new \WeMini\Qrcode($config);
try {
$wxapp = app_http_request("https://api.weixin.qq.com/wxa/generate_urllink?debug=1&access_token=" . $mini->getAccessToken(), $path, [], [], true);
$url = json_decode($wxapp, true);
if ($url["errmsg"] == 'ok') {
Db::name('cx_dyfx_url')->where('id',$id)->update(['url'=>$url['url_link']]);
} else {
$this->error('链接生成失败:' . $url['errcode'] . '--' . $url['errmsg']);
}
} catch (\Exception $e) {
$this->error('链接生成失败,请检查设置:'.$e->getMessage());
throw $e;
}
}
}
if($res){
$this->success("保存成功!", ToUrl('cx_dyfx/url/index'));
}else{
$this->error("保存失败!");
}
}
View::assign([
'url'=>$url
]);
return View::fetch();
}
/**
* @title 删除链接(www.lxh5068.com)
*/
public function del(){
$ids = $this->request->post('ids');
$query = Db::name('cx_dyfx_url')->where('id',$ids)->delete();
if ($query){
$this->success('删除成功');
}else{
$this->error('删除失败');
}
}
}