获取素材总数
@param access_token access_token
@return MaterialcountResult
332984
public static MaterialcountResult get_materialcount(String access_token){
		HttpUriRequest httpUriRequest = RequestBuilder.post()
										.setUri(BASE_URI+"/cgi-bin/material/get_materialcount")
										.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
										.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,MaterialcountResult.class);
	}
360765
protected Pair<AccessToken, RefreshToken> generateAccessTokenOAuthGrantTypes(final AccessTokenRequestDataHolder holder) {
        LOGGER.debug("Creating access token for [{}]", holder.getService());
        val clientId = holder.getRegisteredService().getClientId();
        val authn = DefaultAuthenticationBuilder
            .newInstance(holder.getAuthentication())
            .addAttribute(OAuth20Constants.GRANT_TYPE, holder.getGrantType().toString())
            .addAttribute(OAuth20Constants.SCOPE, holder.getScopes())
            .addAttribute(OAuth20Constants.CLIENT_ID, clientId)
            .build();

        LOGGER.debug("Creating access token for [{}]", holder);
        val ticketGrantingTicket = holder.getTicketGrantingTicket();
        val accessToken = this.accessTokenFactory.create(holder.getService(),
            authn, ticketGrantingTicket, holder.getScopes(), clientId);

        LOGGER.debug("Created access token [{}]", accessToken);
        addTicketToRegistry(accessToken, ticketGrantingTicket);
        LOGGER.debug("Added access token [{}] to registry", accessToken);

        updateOAuthCode(holder);

        val refreshToken = FunctionUtils.doIf(holder.isGenerateRefreshToken(),
            () -> generateRefreshToken(holder),
            () -> {
                LOGGER.debug("Service [{}] is not able/allowed to receive refresh tokens", holder.getService());
                return null;
            }).get();

        return Pair.of(accessToken, refreshToken);
    }
126363
public function getAccessToken()
    {
        if (!empty($this->access_token)) {
            return $this->access_token;
        }
        $cache = $this->config->get('appid') . '_access_token';
        $this->access_token = Tools::getCache($cache);
        if (!empty($this->access_token)) {
            return $this->access_token;
        }
        // 处理开放平台授权公众号获取AccessToken
        if (!empty($this->GetAccessTokenCallback) && is_callable($this->GetAccessTokenCallback)) {
            $this->access_token = call_user_func_array($this->GetAccessTokenCallback, [$this->config->get('appid'), $this]);
            if (!empty($this->access_token)) {
                Tools::setCache($cache, $this->access_token, 7000);
            }
            return $this->access_token;
        }
        list($appid, $secret) = [$this->config->get('appid'), $this->config->get('appsecret')];
        $url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid={$appid}&secret={$secret}";
        $result = Tools::json2arr(Tools::get($url));
        if (!empty($result['access_token'])) {
            Tools::setCache($cache, $result['access_token'], 7000);
        }
        return $this->access_token = $result['access_token'];
    }
1217176
public static CreateResult create(String accessToken, GrouponCard grouponCard) {
		Create<GrouponCard> card = new Create<GrouponCard>();
		card.setCard(grouponCard);
		return create(accessToken, card);
	}
774037
public static ShopGetResult shopGet(String accessToken, ShopInfo shopInfo) {
        return shopGet(accessToken, JsonUtil.toJSONString(shopInfo));
    }
304024
public static Group groupsCreate(String access_token,String name){
		String groupJson = String.format("{\"group\":{\"name\":\"%1$s\"}}",name);
		HttpUriRequest httpUriRequest = RequestBuilder.post()
										.setHeader(jsonHeader)
										.setUri(BASE_URI+"/cgi-bin/groups/create")
										.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
										.setEntity(new StringEntity(groupJson,Charset.forName("utf-8")))
										.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,Group.class);
	}
673817
public function vaildAccessToken(string $access_token, string $open_id)
    {
        $data = [
            'access_token' => $access_token,
            'openid' => $open_id,
        ];
        $url = self::WECHAT.'auth?'.http_build_query($data);
        $data = $this->curl->get($url);

        return Response::json($data);
    }
1024587
public static UploadimgResult mediaUploadimg(String access_token,URI uri){
		HttpPost httpPost = new HttpPost(BASE_URI+"/cgi-bin/media/uploadimg");
		CloseableHttpClient tempHttpClient = HttpClients.createDefault();
		try {
			HttpEntity entity = tempHttpClient.execute(RequestBuilder.get().setUri(uri).build()).getEntity();
			HttpEntity reqEntity = MultipartEntityBuilder.create()
					 .addBinaryBody("media",EntityUtils.toByteArray(entity),ContentType.get(entity),UUID.randomUUID().toString()+".jpg")
			         .addTextBody(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
			         .build();
			httpPost.setEntity(reqEntity);
			return LocalHttpClient.executeJsonResult(httpPost,UploadimgResult.class);
		} catch (Exception e) {
			logger.error("", e);
		} finally{
			try {
				tempHttpClient.close();
			} catch (Exception e) {
				logger.error("", e);
			}
		}
		return null;
	}
791144
public function getOauthUserInfo($access_token, $openid)
    {
        $result = Tools::httpGet(self::API_BASE_URL_PREFIX . self::OAUTH_USERINFO_URL . "access_token={$access_token}&openid={$openid}");
        if ($result) {
            $json = json_decode($result, true);
            if (empty($json) || !empty($json['errcode'])) {
                $this->errCode = isset($json['errcode']) ? $json['errcode'] : '505';
                $this->errMsg = isset($json['errmsg']) ? $json['errmsg'] : '无法解析接口返回内容！';
                Tools::log("WechatOauth::getOauthUserInfo Fail.{$this->errMsg} [{$this->errCode}]", "ERR - {$this->appid}");
                return false;
            }
            return $json;
        }
        return false;
    }
382829
public function getAccessToken(){
		// get stored AccessToken
		$accessToken = $this->getConfig()->getStorage()->getAccessToken();
		if($accessToken !== null && $accessToken->isExpired()){
			// delete AccessToken if expired
			$this->getConfig()->getStorage()->deleteAccessToken();
			$accessToken = null;
		}
		if($accessToken !== null){
			// return AccessToken if stored and not expired
			return $accessToken;
		}
		// no AccessToken stored
		
		// get RefreshToken. May result in valid AccessToken
		$refreshToken = $this->getRefreshToken();
		if(null === $refreshToken){
			// no RefreshToken provided. need to continue polling.
			return null;
		}
		// check if AccessToken was set
		$accessToken = $this->getConfig()->getStorage()->getAccessToken();
		if($accessToken){
			return $accessToken;
		}
		// otherwise fetch new AccessToken with the RefreshToken
		return $this->getAccessTokenWithRefreshToken($refreshToken);
	}
1224002
protected function acquireAccessToken()
	{
		$accessToken = parent::acquireAccessToken();

		if ($this->cache !== null)
			$this->cache->put($this->accessToken);

		return $accessToken;
	}
7939
public static WxamplinkgetResult wxamplinkget(String access_token){
		HttpUriRequest httpUriRequest = RequestBuilder.post()
				.setHeader(jsonHeader)
				.setUri(BASE_URI+"/cgi-bin/wxopen/wxamplinkget")
				.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
				.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,WxamplinkgetResult.class);
	}
1322161
public function getAccessToken()
    {
        if (! $this->accessTokenEntity instanceof AccessTokenEntity) {
            $this->accessTokenEntity = $this->server->getAccessTokenStorage()->get($this->accessTokenId);
        }

        return $this->accessTokenEntity;
    }
161004
public static Media mediaUploadvideo(String access_token,Uploadvideo uploadvideo){
		String messageJson = JsonUtil.toJSONString(uploadvideo);
		HttpUriRequest httpUriRequest = RequestBuilder.post()
										.setHeader(jsonHeader)
										//2.8.20 修改URI  原URI MEDIA_URI+"/cgi-bin/media/uploadvideo"
										.setUri(BASE_URI+"/cgi-bin/media/uploadvideo")
										.addParameter(PARAM_ACCESS_TOKEN, API.accessToken(access_token))
										.setEntity(new StringEntity(messageJson,Charset.forName("utf-8")))
										.build();
		return LocalHttpClient.executeJsonResult(httpUriRequest,Media.class);
	}
1286028
public function checkAccessToken($access_token = null)
    {
        $token = is_null($access_token) ? $this->access_token : $access_token;
        if (is_null($token)) return false;

        $rs = $this->api('getUserSettings', array('access_token' => $token));
        return isset($rs['response']);
    }
513208
public function setAccessToken($access_token)
    {
        if (!is_string($access_token)) {
            throw new InvalidArgumentException("Invalid AccessToken type, need string.");
        }
        $cache = $this->config->get('appid') . '_access_token';
        Tools::setCache($cache, $this->access_token = $access_token);
    }
257235
public static function refreshToken(AccessToken $token, $params = null)
    {
        if ($token->expires_at > new \DateTime()) {
            return $token;
        }

        $requestor = new ApiRequestor(Sumup::$connectBase, true);
        $params = [
            'grant_type' => 'refresh_token',
            'client_id' => self::_getConnectParam('client_id', $params),
            'client_secret' => self::_getConnectParam('client_secret', $params),
            'refresh_token' => $token->refresh_token
        ];
        $response = $requestor->request('post', '/token', $params);

        if ($response->raw->getStatusCode() !== 200) {
            throw new Error\AuthenticationError('Token request error');
        }

        return new AccessToken($response);
    }