调用 get_xcs_qr_img($pdo,$scene)即可
function get_xcs_access_token($pdo){
if(null ==SITE_ID){return false;}
$token_path='f/'.SITE_ID.'/xcs_access.sql';
if(is_file($token_path)){
$r=file_get_contents($token_path);
$r=json_decode($r,1);
if($r['expires_in']>time()){return $r['access_token'];}
}
$c=get_config_data($pdo,'/payment/wxxcs/config.php');
//var_dump($c);
if($c['appid']=='' || $c['appsecret']==''){return false;}
$url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$c['appid']."&secret=".$c['appsecret'];
$data = '{"name":sucaihuo}';
$tokens= https_post($url,$data);
$tokens = json_decode($tokens, true);
$tokens['expires_in']=time()+$tokens['expires_in']-100;
file_put_contents($token_path,json_encode($tokens));
return $tokens['access_token'];
}
function get_xcs_qr_img($pdo,$scene){
$tokens=get_xcs_access_token($pdo);
if(!$tokens){return '';}
$url = 'https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=' . $tokens;
$width = 100;
$is_hyaline = 'true'; //
$auto_color = 'false'; //默认值是false,自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调;
$line_color = '{"r":"0","g":"0","b":"0"}'; //auth_color 为 false 时生效,使用 rgb 设置颜色 例如 {"r":"xxx","g":"xxx","b":"xxx"}
$data = '{"scene":"' . $scene . '","width":' . $width . ',"auto_color":' . $auto_color . ',"line_color":' . $line_color . '}';
$c = https_post($url, $data);
return $c;
}