Exemple #1
0
        public VkJsonRequest Send(Message message, params int[] id)
        {
            var parameters = new VKParameters();

            if (id.Length == 1)
            {
                parameters.Add(VKApiConst.USER_ID, id[0]);
            }
            else
            {
                parameters.Add(VKApiConst.USER_IDS, string.Join(",", id));
            }

            parameters.Add(VKApiConst.MESSAGE, message.body);
            return PrepareJsonRequest("send", parameters, AbstractRequest.HttpMethod.GET);
        }
Exemple #2
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.Add(VKApiConst.ACCESS_TOKEN, token.accessToken);
                if (!secure)
                    if (token != null && (token.secret != null || token.httpsRequired))
                    {
                        secure = true;
                    }
                //Set actual version of API
                if (!mPreparedParameters.ContainsKey(VKApiConst.VERSION))
                    mPreparedParameters.Add(VKApiConst.VERSION, VKSdkVersion.API_VERSION);
                //Set preferred language for request
                if (!mPreparedParameters.ContainsKey(VKApiConst.LANG))
                    mPreparedParameters.Add(VKApiConst.LANG, GetLang());

                if (secure)
                {
                    //If request is secure, we need all urls as https
                    mPreparedParameters.Add(VKApiConst.HTTPS, "1");
                }
                if (token != null && token.secret != null)
                {
                    //If it not, generate signature of request
                    string sig = GenerateSig(token);
                    mPreparedParameters.Add(VKApiConst.SIG, sig);
                }
                //From that moment you cannot modify parameters.
                //Specially for http loading
            }
            return mPreparedParameters;
        }
Exemple #3
0
        /**
         * Serialize token into string
         *
         * @return Serialized token string as query-string
         */
        public override string ToString()
        {
            var parameters = new VKParameters
            {
                {ACCESS_TOKEN, accessToken},
                {EXPIRES_IN, expiresIn},
                {USER_ID, userId},
                {CREATED, created}
            };

            if (secret != null)
            {
                parameters.Add(SECRET, secret);
            }
            if (httpsRequired)
            {
                parameters.Add(HTTPS_REQUIRED, "1");
            }

            return VKstringJoiner.joinParams(parameters);
        }
Exemple #4
0
 /**
  * Repeats failed captcha request with user entered answer to captcha
  *
  * @param userEnteredCode answer for captcha
  */
 public void answerCaptcha(string userEnteredCode)
 {
     VKParameters parameters = new VKParameters();
     parameters.Add(VKApiConst.CAPTCHA_SID, captchaSid);
     parameters.Add(VKApiConst.CAPTCHA_KEY, userEnteredCode);
     request.addExtraParameters(parameters);
     request.Repeat();
 }