公众号更新菜单
public function generateMenu_POST(){ check_dl_login(); $this->valid([ 'we_id' => ['require' => true,'regex' => $_TMP['regexs']['id']] ]); $where['we_id='] = $this->post['we_id']; $where['dl_id='] = $_SESSION['user_id']; $info = $this->sql('xs.wechat')->select('dl_id,we_id,original_id,we_username,we_nickname,we_appid as appid,we_appsecret as appkey,we_mode,we_href,is_account_each')->where($where)->query(); if(count($info)==1){ $this->wechat = $info[0]; $this->appid = $this->wechat['appid']; $wechat_C = $this->class('wechat'); $wechat_C->wechat($this->wechat); $xs_url = 'http://b'.$info[0]['dl_id'].'.'.$info[0]['we_id'].'.'.(isset($_CONFIG['B_'.$this->wechat['dl_id']]) ? $_CONFIG['B_'.$this->wechat['dl_id']] : NOW_HOST); $xml_arr = [ 'button' => [ [ 'type' => 'view', 'name' => '阅读记录', 'url' => $xs_url . '/history?clear=1', ], [ 'name' => '访问书城', 'sub_button' => [ [ 'type' => 'view', 'name' => '书城首页', 'url' => $xs_url.'?clear=1', ], [ 'type' => 'view', 'name' => '免费专区', 'url' => $xs_url.'/free?clear=1', ], ] ], [ 'name' => '送书币', 'sub_button' => [ // [ // 'type' => 'view', // 'name' => '💸双倍特惠', // 'url' => 'http://pay.'.(isset($_CONFIG['B_'.$this->wechat['dl_id']]) ? $_CONFIG['B_'.$this->wechat['dl_id']] : NOW_HOST).'/pay/actpay/'.$info[0]['dl_id'].'.'.$info[0]['we_id'].'?clear=1', // ], [ 'type' => 'click', 'name' => '领书币', 'key' => 'sign', ], [ 'type' => 'view', 'name' => '🔥我要充值', 'url' => 'http://pay.'.(isset($_CONFIG['B_'.$this->wechat['dl_id']]) ? $_CONFIG['B_'.$this->wechat['dl_id']] : NOW_HOST).'/pay/pay/'.$info[0]['dl_id'].'.'.$info[0]['we_id'].'?clear=1', ], [ 'type' => 'view', 'name' => '我的书架', 'url' => $xs_url . '/bookmark?clear=1', ] ] ] ] ]; if(in_array($info[0]['we_id'], $_CONFIG['SHARE_WEID'])){ array_splice($xml_arr['button'][2]['sub_button'], 2, 0, [[ 'type' => 'view', 'name' => '🔥分享赚钱', 'url' => $xs_url . '/earnings?clear=1', ]]); } if(isset($_CONFIG['CAR_WEID'][$info[0]['we_id']])){ array_splice($xml_arr['button'][1]['sub_button'], 1, 0, [[ 'type' => 'view', 'name' => '立即上车', 'url' => $xs_url . '/read/'.$_CONFIG['CAR_WEID'][$info[0]['we_id']].'?clear=1', ]]); } $rt = curl_do('https://api.weixin.qq.com/cgi-bin/menu/create?access_token='.$wechat_C->token(),json_encode($xml_arr, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES),'POST'); if($rt[0] === 200){ $rt_arr = json_decode($rt[1],true); if($rt_arr['errcode']==0){ out('{"rt":0,"msg":"success"}'); }else{ out('{"rt":500,"msg":"微信接口请求失败"}'); } }else{ out('{"rt":500,"msg":"微信接口请求失败"}'); } }else{ out('{"rt":601,"msg":"微信公众号不存在"}'); } }