-
Notifications
You must be signed in to change notification settings - Fork 0
/
bindWorkWX.php
32 lines (29 loc) · 1.68 KB
/
bindWorkWX.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
header("content-type:text/html;charset=utf-8");
include_once(__DIR__."/common.php");
$data = initPostData();
$token = $data['token'];
$ww_userid = $data['ww_userid'];
$pay_name = $data['pay_name'];
// 绑定企业微信管理后台
// 格式:/bind $token $payName,直接粘贴到企业微信即可
$input = array(':token'=>$token, ':ww_userid'=>$ww_userid, ':pay_name'=>$pay_name);
$con = pdo_database();
$sql = "UPDATE userinfo SET ww_userid = :ww_userid WHERE login_token = :token";// AND ww_userid IS NULL";
$sth = $con->prepare($sql,array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$sth->execute(array(':token'=>$token, ':ww_userid'=>$ww_userid));
$sql = "UPDATE userinfo SET pay_name = :pay_name WHERE login_token = :token AND ww_userid = :ww_userid";
$sth = $con->prepare($sql,array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$sth->execute($input);
$sql = "SELECT id,nickName FROM userinfo WHERE login_token = :token AND ww_userid = :ww_userid AND pay_name = :pay_name";
$sth = $con->prepare($sql,array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
$sth->execute($input);
$res = $sth->fetch(PDO::FETCH_ASSOC);
$nickName = $res['nickName'];
if($nickName){
sc_send($title = "您已成功使用企业微信绑定小程序管理后台",$text = "您的企业微信ID是 $ww_userid\n您的账单用昵称为 $pay_name\n您的微信昵称为 $nickName\n如有错漏请联系@离离沐雪",$type = 'text',$touser = $ww_userid, $toparty = '', $IsJson = true);
}
else{
sc_send($title = "企业微信绑定失败!",$text = "请尝试在小程序重新认证信息以刷新token,如果还不成功请联系@离离沐雪",$type = 'text',$touser = $ww_userid, $toparty = '', $IsJson = true);
}
$con = null;