<?php require '/inc/odbc.php';?>
|
<?php
|
|
//获取access_token(系统提示)
|
Function GetAccess_token_1000006() {
|
global $conn;
|
$access_tokenID=6089; //对应数据库ID
|
$corpid="wx248505bfbab6d0c1";
|
$corpsecret="zXfzkk8wBJIZjrxq7BwZ1ckG2505cpNuSlJH1m8i-6Y";
|
$sql="select vtext,vMono from dictionary where id=$access_tokenID";
|
$data = sqlsrv_query($conn,$sql);
|
if($data == true){
|
if (sqlsrv_rows_affected($data)!=0) {
|
while($rs = sqlsrv_fetch_array($data) ) {
|
$access_token=$rs["vtext"];
|
$access_token_time=date_timestamp_get(date_create($rs["vMono"]));
|
if (time() >= $access_token_time) {
|
//获取新的access_token
|
$api_url="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$corpsecret";
|
$api_info=file_get_contents($api_url);
|
$api_info=json_decode($api_info,true);
|
$errcode = $api_info["errcode"];
|
if ($errcode==0) {
|
$access_token=$api_info["access_token"];
|
//echo $access_token;
|
//写入数据库
|
$sql="update dictionary set vtext='".$access_token."',vMono='".date("Y-m-d H:i:s",time()+7100)."' where id=$access_tokenID";
|
$UPsql = sqlsrv_query($conn,$sql);
|
}
|
}
|
}
|
}
|
}
|
return $access_token;
|
}
|
|
//获取access_token(调度分派)
|
Function GetAccess_token_21() {
|
global $conn;
|
$access_tokenID=1; //对应数据库ID
|
$corpid="wx248505bfbab6d0c1";
|
$corpsecret="2MCilqWYC0FWjOQ894sbb-s7Lb5sVH4HHuJgOsd9l1k";
|
$sql="select vtext,vMono from dictionary where id=$access_tokenID";
|
$data = sqlsrv_query($conn,$sql);
|
if($data == true){
|
if (sqlsrv_rows_affected($data)!=0) {
|
while($rs = sqlsrv_fetch_array($data) ) {
|
$access_token=$rs["vtext"];
|
$access_token_time=date_timestamp_get(date_create($rs["vMono"]));
|
if (time() >= $access_token_time) {
|
//获取新的access_token
|
$api_url="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$corpsecret";
|
$api_info=file_get_contents($api_url);
|
$api_info=json_decode($api_info,true);
|
$errcode = $api_info["errcode"];
|
if ($errcode==0) {
|
$access_token=$api_info["access_token"];
|
//echo $access_token;
|
//写入数据库
|
$sql="update dictionary set vtext='".$access_token."',vMono='".date("Y-m-d H:i:s",time()+7100)."' where id=$access_tokenID";
|
$UPsql = sqlsrv_query($conn,$sql);
|
}
|
}
|
}
|
}
|
}
|
return $access_token;
|
}
|
|
//获取access_token(合作报表)
|
Function GetAccess_token_1000004() {
|
global $conn;
|
$access_tokenID=5698; //对应数据库ID
|
$corpid="wx248505bfbab6d0c1";
|
$corpsecret="6fuEHzsvx0KGuZyjoDic9W1YNsbOzWP65_rj3s3gm-E";
|
$sql="select vtext,vMono from dictionary where id=$access_tokenID";
|
$data = sqlsrv_query($conn,$sql);
|
if($data == true){
|
if (sqlsrv_rows_affected($data)!=0) {
|
while($rs = sqlsrv_fetch_array($data) ) {
|
$access_token=$rs["vtext"];
|
$access_token_time=date_timestamp_get(date_create($rs["vMono"]));
|
if (time() >= $access_token_time) {
|
//获取新的access_token
|
$api_url="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$corpsecret";
|
$api_info=file_get_contents($api_url);
|
$api_info=json_decode($api_info,true);
|
$errcode = $api_info["errcode"];
|
if ($errcode==0) {
|
$access_token=$api_info["access_token"];
|
//echo $access_token;
|
//写入数据库
|
$sql="update dictionary set vtext='".$access_token."',vMono='".date("Y-m-d H:i:s",time()+7100)."' where id=$access_tokenID";
|
$UPsql = sqlsrv_query($conn,$sql);
|
}
|
}
|
}
|
}
|
}
|
return $access_token;
|
}
|
|
//获取access_token(优惠券生成)
|
Function GetAccess_token_1000016() {
|
global $conn;
|
$access_tokenID=7056; //对应数据库ID
|
$corpid="wx248505bfbab6d0c1";
|
$corpsecret="zXfzkk8wBJIZjrxq7BwZ1ckG2505cpNuSlJH1m8i-6Y";
|
$sql="select vtext,vMono from dictionary where id=$access_tokenID";
|
$data = sqlsrv_query($conn,$sql);
|
if($data == true){
|
if (sqlsrv_rows_affected($data)!=0) {
|
while($rs = sqlsrv_fetch_array($data) ) {
|
$access_token=$rs["vtext"];
|
$access_token_time=date_timestamp_get(date_create($rs["vMono"]));
|
if (time() >= $access_token_time) {
|
//获取新的access_token
|
$api_url="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$corpsecret";
|
$api_info=file_get_contents($api_url);
|
$api_info=json_decode($api_info,true);
|
$errcode = $api_info["errcode"];
|
if ($errcode==0) {
|
$access_token=$api_info["access_token"];
|
//echo $access_token;
|
//写入数据库
|
$sql="update dictionary set vtext='".$access_token."',vMono='".date("Y-m-d H:i:s",time()+7100)."' where id=$access_tokenID";
|
$UPsql = sqlsrv_query($conn,$sql);
|
}
|
}
|
}
|
}
|
}
|
return $access_token;
|
}
|
|
//获取access_token(通讯录同步专用 https://work.weixin.qq.com/wework_admin/frame#apps/contactsApi)
|
Function GetAccess_token_contactsApi() {
|
global $conn;
|
$access_tokenID=6557; //对应数据库ID
|
$corpid="wx248505bfbab6d0c1";
|
$corpsecret="TjLL-dIOllJ_-WeF8N90DVzWn02vva4Xuf3PlytgDSo";
|
$sql="select vtext,vMono from dictionary where id=$access_tokenID";
|
$data = sqlsrv_query($conn,$sql);
|
if($data == true){
|
if (sqlsrv_rows_affected($data)!=0) {
|
while($rs = sqlsrv_fetch_array($data) ) {
|
$access_token=$rs["vtext"];
|
$access_token_time=date_timestamp_get(date_create($rs["vMono"]));
|
if (time() >= $access_token_time) {
|
//获取新的access_token
|
$api_url="https://qyapi.weixin.qq.com/cgi-bin/gettoken?corpid=$corpid&corpsecret=$corpsecret";
|
$api_info=file_get_contents($api_url);
|
$api_info=json_decode($api_info,true);
|
$errcode = $api_info["errcode"];
|
if ($errcode==0) {
|
$access_token=$api_info["access_token"];
|
//echo $access_token;
|
//写入数据库
|
$sql="update dictionary set vtext='".$access_token."',vMono='".date("Y-m-d H:i:s",time()+7100)."' where id=$access_tokenID";
|
$UPsql = sqlsrv_query($conn,$sql);
|
}
|
}
|
}
|
}
|
}
|
return $access_token;
|
}
|
?>
|