12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?php
- /**
- * [WeEngine System] Copyright (c) 2014 WE7.CC
- * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details.
- */
- defined('IN_IA') or exit('Access Denied');
- class BaiduappAccount extends WeAccount {
- protected $tablename = 'account_baiduapp';
- protected $menuFrame = 'wxapp';
- protected $type = ACCOUNT_TYPE_BAIDUAPP_NORMAL;
- protected $typeName = '百度小程序';
- protected $typeTempalte = '-baiduapp';
- protected $typeSign = BAIDUAPP_TYPE_SIGN;
- protected $supportVersion = STATUS_ON;
- protected function getAccountInfo($uniacid) {
- return table('account_baiduapp')->getAccount($uniacid);
- }
- public function getAccessToken() {
- global $_W;
- $cachekey = cache_system_key('accesstoken', array('uniacid' => $this->account['uniacid']));
- $cache = cache_load($cachekey);
- if (!empty($cache) && !empty($cache['token'])) {
- $this->account['access_token'] = $cache;
- return $cache['token'];
- }
- if (empty($this->account['link'])) {
- return error(-1, '参数错误!');
- }
- load()->library('sdk-module');
- $link_config = iunserializer($this->account['link_config']);
- try {
- $api = new \W7\Sdk\Module\Api($_W['setting']['site']['key'], $_W['setting']['site']['token'], $link_config['app_id'], 6, CLOUD_V3API_DOMAIN_PRE);
- $token = $api->app()->getAccessToken()->toArray();
- } catch (Exception $e) {
- return error('-1', $e->getMessage());
- }
- $record = array();
- $record['token'] = $token['access_token'];
- $record_expire = $token['expires_in'] - 200;
- $this->account['access_token'] = $record;
- cache_write($cachekey, $record, $record_expire);
- return $record['token'];
- }
- }
|