获取指定应用的指定用户积分
本接口函数用于获取指定应用的指定用户积分。

@param int $appid 应用 ID
@param int $uid 用户 ID
@param int $credit 积分编号
@return int
161598
public function userGetCredit($appid, $uid, $credit)
    {
        $response = $this->apiPost('user', 'getcredit', compact('appid', 'uid', 'credit'));
        return (int)$response;
    }
414950
public function decrypt($encrypted, $appid)
    {

		try {
			//使用BASE64对需要解密的字符串进行解码
			$ciphertext_dec = base64_decode($encrypted);
			$module = mcrypt_module_open(MCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, '');
			$iv = substr($this->key, 0, 16);
			mcrypt_generic_init($module, $this->key, $iv);

			//解密
			$decrypted = mdecrypt_generic($module, $ciphertext_dec);
			mcrypt_generic_deinit($module);
			mcrypt_module_close($module);
		} catch (\Exception $e) {
			@error_log('Decrypt AES Error: ' . $e->getMessage(), 0);
			return FALSE;
		}


		try {
			//去除补位字符
			$pkc_encoder = new Pkcs7Encoder;
			$result = $pkc_encoder->decode($decrypted);
			//去除16位随机字符串,网络字节序和AppId
			if (strlen($result) < 16) {
				return "";
			}
			$content = substr($result, 16, strlen($result));
			$len_list = unpack("N", substr($content, 0, 4));
			$xml_len = $len_list[1];
			$xml_content = substr($content, 4, $xml_len);
			$from_appid = substr($content, $xml_len + 4);
		} catch (\Exception $e) {
			@error_log('Illegal Buffer: ' . $e->getMessage(), 0);
			return FALSE;
		}
		if ($from_appid != $appid) {
			@error_log('Validate Appid Error', 0);
			return FALSE;
		}
		return $xml_content;
	}
321945
public function thirdAccountInformation($uid = '') {
        $component_access_token = $this->componentAccessToken();
        #提交数据
        $data = array(
            "component_appid"  => C("wechat", "componentAppid"),
            "authorizer_appid" => $this->getUidAppid($uid, "appid"),
        );
        #提交的URL地址
        $url = "https://api.weixin.qq.com/cgi-bin/component/api_get_authorizer_info?component_access_token=$component_access_token";
        $res = to_array($this->httpPost($url, $data));
        if ($res && isset($res['authorizer_info'])) {
            return $res;
        } else {
            return false;
        }
    }
619340
public function getGroups($uid)
    {
        static $groups = [];
        if (isset($groups[$uid])) {
            return $groups[$uid];
        }
        // 转换表名
        $type = Config::get('database.prefix') ? 1 : 0;
        $auth_group_access = Loader::parseName($this->config['auth_group_access'], $type);
        $auth_group = Loader::parseName($this->config['auth_group'], $type);
        // 执行查询
        $user_groups = Db::view($auth_group_access, 'uid,group_id')
            ->view($auth_group, 'title,rules', "{$auth_group_access}.group_id={$auth_group}.id", 'LEFT')
            ->where("{$auth_group_access}.uid='{$uid}' and {$auth_group}.status='1'")
            ->select();
        $groups[$uid] = $user_groups ?: [];

        return $groups[$uid];
    }
141436
public function getUserInfo($uid) {

        $userinfo = [];

        if (empty($this->userInfo)){

            $userinfo = $this->config['auth_cache'] ? Session::get($this->getUserKey($uid)) : [];

            if (empty($userinfo) || !is_array($userinfo)){
                $user = Db::name($this->config['users']);
                // 获取用户表主键
                $_pk = is_string($user->getPk()) ? $user->getPk() : 'id';

                $userinfo = $user->field($this->config['users_auth_fields'])->where($_pk, $uid)->find();

                if ($this->config['auth_cache'])
                    Session::set($this->getUserKey($uid),$userinfo);
            }


            $this->userInfo = $userinfo;
        }

        return $this->userInfo;
    }
1008873
public function listUser($appId, $roomName)
    {
        $url = sprintf("%s/%s/rooms/%s/users", $this->baseURL, $appId, $roomName);
        $ret  = $this->get($url);
        return $ret;
    }
360398
protected function getItemByUid($data, $uid)
    {
        /* @var Shopgate_Model_Abstract $item */
        foreach ($data as $item) {
            if ($item->getData(self::DEFAULT_IDENTIFIER_UID) == $uid) {
                return $item;
            }
        }

        return false;
    }
129668
function getAccountInfoByUid($uid)
    {
        $response = $this->call( new Command\AccountInfo($uid, Command\AccountInfo::TYPE_UID) );
        if ( $ex = $response->hasException() )
            throw $ex;

        $r = $response->expected();
        $r = ($r instanceof iDataEntity) ? $r->get('result') : $r;
        return $r;
    }
1138464
public function getPageByUid(int $uid, int $languageUid = null) {
    return $this->getPage($uid, $languageUid);
  }
332092
public function findAll($appUserId)
    {
        $url = sprintf('users/%s/subaccounts/', $appUserId);
        return $this->getAll($url, $this->entityClassName);
    }
288311
public function getSize($cb, $uid = null)
    {
        $this->onResponse->push($cb);
        if ($uid) {
            $this->fetch('RFC822.SIZE', $uid, null, true, self::TAG_SIZE);
        } else {
            $this->fetch('RFC822.SIZE', 1, INF, true, self::TAG_SIZE);
        }
    }
894152
public function updateUserRemark($uid, $remark = null) {
		$user = WechatUser::findOne($uid);
		if(!$user) {
			throw new ErrorException('数据查询失败');
		}

		$data = $this->getData('/cgi-bin/user/info/updateremark', [
			'access_token' => $this->getAccessToken(),
		], Json::encode([
			'openid' => $user->openid,
			'remark' => $remark ? : $user->remark,
		]));

		$result = $this->errcode == 0;
		if($result && $remark) {
			$user->remark = $remark;
			$user->save();
		}

		return $result;
	}
326270
public static function getJsapiTicket($app_id, $app_secret) {
        $urlObj = array();
        $urlObj['appid'] = $app_id;
        $urlObj['secret'] = $app_secret;
        $urlObj['grant_type'] = 'client_credential';
        $queryStr = http_build_query($urlObj);
        $accessTokenUrl = 'https://api.weixin.qq.com/cgi-bin/token?' . $queryStr;
        $resp = self::_getRequest($accessTokenUrl);
        $resp = json_decode($resp, true);
        if (!is_array($resp) || isset($resp['errcode'])) {
            return $resp;
        }

        $urlObj = array();
        $urlObj['access_token'] = $resp['access_token'];
        $urlObj['type'] = 'jsapi';
        $queryStr = http_build_query($urlObj);
        $jsapiTicketUrl = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?' . $queryStr;
        $resp = self::_getRequest($jsapiTicketUrl);

        return json_decode($resp, true);
    }
274565
public function getUniqueId($cb, $id = null)
    {
        $this->onResponse->push($cb);
        if ($id) {
            $this->fetch('UID', $id, null, false, self::TAG_GETUID);
        } else {
            $this->fetch('UID', 1, INF, false, self::TAG_GETUID);
        }
    }
806777
public function getPage(int $uid, int $languageUid = null) {
    $page   = null;
    $record = Page::find($uid);

    if ($record) {
      $record = $record->getAttributes();

      if (is_array($record) && !empty($record) && in_array($record['doktype'], self::PAGE_DOKTYPES)) {
        $page                  = $record;
        $l18nCfg               = isset($page['l18n_cfg']) ? $page['l18n_cfg'] : 0;
        $hideIfDefaultLanguage = (boolean) GeneralUtility::hideIfDefaultLanguage($l18nCfg);
        $hideIfNotTranslated   = (boolean) GeneralUtility::hideIfNotTranslated($l18nCfg);
        $languageUid           = isset($languageUid) ? $languageUid : $this->languageService->getLanguageUid();

        if ($hideIfDefaultLanguage) {
          $page['hidden'] = 1;
        }

        if ($languageUid > 0) {
          $constraints     = [['pid', '=', $uid], ['sys_language_uid', '=', $languageUid], ['deleted', '=', 0]];
          $languageOverlay = LanguageOverlay::where($constraints)->first();

          if ($languageOverlay) {
            $languageOverlayAttributes = [];
            $attributes                = $languageOverlay->getAttributes();

            foreach (self::PAGE_LANGUAGE_OVERLAY_ATTRIBUTES as $attribute) {
              if (is_string($attributes[$attribute]) && empty($attributes[$attribute])) {
                continue;
              }

              $languageOverlayAttributes[$attribute] = $attributes[$attribute];
            }

            $page = array_merge($page, $languageOverlayAttributes);

            if ($this->extensionService->runningInFallbackMode() && !$hideIfDefaultLanguage && !$hideIfNotTranslated) {
              $page['hidden'] = 0;
            }
          }
        }
      }
    }

    return $page;
  }
1302751
public function decrypt($encrypted, $appId)
    {
        try {
            //使用BASE64对需要解密的字符串进行解码
            $key        = $this->getAESKey();
            $ciphertext = base64_decode($encrypted, true);
            $iv         = substr($key, 0, 16);

            $decrypted = openssl_decrypt($ciphertext, 'aes-256-cbc', $key, OPENSSL_RAW_DATA | OPENSSL_NO_PADDING, $iv);
        } catch (Exception $e) {
            return [ErrorCode::$DecryptAESError, null];
        }

        try {
            $result = $this->decode($decrypted);

            if (strlen($result) < 16) {
                return '';
            }

            $content   = substr($result, 16, strlen($result));
            $listLen   = unpack('N', substr($content, 0, 4));
            $xmlLen    = $listLen[1];
            $xml       = substr($content, 4, $xmlLen);
            $fromAppId = trim(substr($content, $xmlLen + 4));
        } catch (Exception $e) {
            //print $e;
            return [ErrorCode::$IllegalBuffer, null];
        }
        if ($fromAppId !== $appId) {
            return [ErrorCode::$ValidateAppidError, null];
        }

        $dataSet = json_decode($xml, true);
        if ($dataSet && (JSON_ERROR_NONE === json_last_error())) {
            // For mini-program JSON formats.
            // Convert to XML if the given string can be decode into a data array.
            $xml = XML::build($dataSet);
        }

        return [ErrorCode::$OK, $xml];
    }
801006
public function setAppId($appId = null)
    {
        return $this->set($this->appIdColumn, $appId ?: wei()->app->getId());
    }