Ejemplo n.º 1
0
  public VKParameters getPreparedParameters() {
    if (mPreparedParameters == null) {
      mPreparedParameters = new VKParameters(mMethodParameters);

      // Set current access token from SDK object
      VKAccessToken token = VKSdk.getAccessToken();
      if (token != null) mPreparedParameters.put(VKApiConst.ACCESS_TOKEN, token.accessToken);
      if (!this.secure)
        if (token != null && (token.secret != null || token.httpsRequired)) {
          this.secure = true;
        }
      // Set actual version of API
      mPreparedParameters.put(VKApiConst.VERSION, VKSdkVersion.API_VERSION);
      // Set preferred language for request
      mPreparedParameters.put(VKApiConst.LANG, getLang());

      if (this.secure) {
        // If request is secure, we need all urls as https
        mPreparedParameters.put(VKApiConst.HTTPS, "1");
      }
      if (token != null && token.secret != null) {
        // If it not, generate signature of request
        String sig = generateSig(token);
        mPreparedParameters.put(VKApiConst.SIG, sig);
      }
      // From that moment you cannot modify parameters.
      // Specially for http loading
    }
    return mPreparedParameters;
  }
Ejemplo n.º 2
0
  private boolean processCommonError(VKError error) {
    if (error.errorCode == VKError.VK_API_ERROR) {
      if (error.apiError.errorCode == 14) {
        error.apiError.request = this;
        this.mLoadingOperation = null;
        VKSdk.instance().sdkListener().onCaptchaError(error.apiError);
        return true;
      } else if (error.apiError.errorCode == 16) {
        VKAccessToken token = VKSdk.getAccessToken();
        token.httpsRequired = true;
        repeat();
        return true;
      } else if (error.apiError.errorCode == 17) {
        Intent i = new Intent(VKUIHelper.getTopActivity(), VKOpenAuthActivity.class);
        i.putExtra(VKOpenAuthActivity.VK_EXTRA_VALIDATION_URL, error.apiError.redirectUri);
        i.putExtra(VKOpenAuthActivity.VK_EXTRA_VALIDATION_REQUEST, this.registerObject());
        VKUIHelper.getTopActivity().startActivityForResult(i, VKSdk.VK_SDK_REQUEST_CODE);
        return true;
      }
    }

    return false;
  }