Exemple #1
0
        public async Task <VkPhoto> SaveWallPhoto(string server, string photo, string hash, long userId = 0, long groupId = 0)
        {
            var parameters = new Dictionary <string, string>();

            parameters.Add("server", server);
            parameters.Add("photo", photo);
            parameters.Add("hash", hash);

            if (userId != 0)
            {
                parameters.Add("user_id", userId.ToString());
            }

            if (groupId != 0)
            {
                parameters.Add("group_id", groupId.ToString());
            }

            parameters.Add("access_token", _vkontakte.AccessToken.Token);

            var response = await VkRequest.GetAsync(VkConst.MethodBase + "photos.saveWallPhoto", parameters);

            if (response["response"] != null)
            {
                return(VkPhoto.FromJson(response["response"].First));
            }

            return(null);
        }
Exemple #2
0
        public async Task <VkPhoto> SaveMessagePhoto(string server, string photo, string hash)
        {
            if (_vkontakte.AccessToken == null || string.IsNullOrEmpty(_vkontakte.AccessToken.Token) || _vkontakte.AccessToken.HasExpired)
            {
                throw new Exception("Access token is not valid.");
            }

            var parameters = new Dictionary <string, string>();

            parameters.Add("server", server);
            parameters.Add("photo", photo);
            parameters.Add("hash", hash);

            _vkontakte.SignMethod(parameters);

            var response = await VkRequest.GetAsync(VkConst.MethodBase + "photos.saveMessagesPhoto", parameters);

            if (response["response"] != null)
            {
                return(VkPhoto.FromJson(response["response"].First));
            }

            return(null);
        }
Exemple #3
0
        public async Task <VkPhoto> SaveWallPhoto(string server, string photo, string hash, long userId = 0, long groupId = 0)
        {
            if (_vkontakte.AccessToken == null || string.IsNullOrEmpty(_vkontakte.AccessToken.Token) || _vkontakte.AccessToken.HasExpired)
            {
                throw new Exception("Access token is not valid.");
            }

            var parameters = new Dictionary <string, string>();

            parameters.Add("server", server);
            parameters.Add("photo", photo);
            parameters.Add("hash", hash);

            if (userId != 0)
            {
                parameters.Add("user_id", userId.ToString());
            }

            if (groupId != 0)
            {
                parameters.Add("group_id", groupId.ToString());
            }

            parameters.Add("access_token", _vkontakte.AccessToken.Token);

            var response = await new VkRequest(new Uri(VkConst.MethodBase + "photos.saveWallPhoto"), parameters).Execute();

            VkErrorProcessor.ProcessError(response);

            if (response["response"] != null)
            {
                return(VkPhoto.FromJson(response["response"].First));
            }

            return(null);
        }