Beispiel #1
0
 public void SetCommunityServices(long id, int wallOrComments, int photos, int videos, int audios, int documents, int discussions, int links, int events, int contacts, int strongLanguageFilter, int keyWordsFilter, string keyWords, Action <BackendResult <int, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <int>("groups.edit", new Dictionary <string, string>()
     {
         {
             "group_id",
             id.ToString()
         },
         {
             "wall",
             wallOrComments.ToString()
         },
         {
             "photos",
             photos.ToString()
         },
         {
             "video",
             videos.ToString()
         },
         {
             "audio",
             audios.ToString()
         },
         {
             "docs",
             documents.ToString()
         },
         {
             "topics",
             discussions.ToString()
         },
         {
             "links",
             links.ToString()
         },
         {
             "events",
             events.ToString()
         },
         {
             "contacts",
             contacts.ToString()
         },
         {
             "obscene_filter",
             strongLanguageFilter.ToString()
         },
         {
             "obscene_stopwords",
             keyWordsFilter.ToString()
         },
         {
             "obscene_words",
             keyWords
         }
     }, callback, null, false, true, new CancellationToken?(), null);
 }
Beispiel #2
0
        public void CopyPhotos(long ownerId, long photoId, string accessKey, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["owner_id"]   = ownerId.ToString();
            parameters["photo_id"]   = photoId.ToString();
            parameters["access_key"] = accessKey.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("photos.copy", parameters, callback, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Beispiel #3
0
        public void GetById(long owner_id, long poll_id, bool is_board, Action <BackendResult <Poll, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["owner_id"] = owner_id.ToString();
            parameters["poll_id"]  = poll_id.ToString();
            parameters["is_board"] = is_board.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <Poll>("polls.getById", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Beispiel #4
0
        public void ReportComment(long ownerId, long commentId, ReportReason reportReason, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["owner_id"]   = ownerId.ToString();
            parameters["comment_id"] = commentId.ToString();
            parameters["reason"]     = ((int)reportReason).ToString();
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("photos.reportComment", parameters, callback, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Beispiel #5
0
        public void DeleteComment(long ownerId, long vid, long cid, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["owner_id"]   = ownerId.ToString();
            parameters["video_id"]   = vid.ToString();
            parameters["comment_id"] = cid.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("video.deleteComment", parameters, callback, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Beispiel #6
0
        public void DeleteComment(long gid, long tid, long cid, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["group_id"]   = gid.ToString();
            parameters["topic_id"]   = tid.ToString();
            parameters["comment_id"] = cid.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("board.deleteComment", parameters, callback, (Func <string, ResponseWithId>)(j => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
        public void GetRecommended(long uid, long offset, long count, Action <BackendResult <List <AudioObj>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["user_id"] = uid.ToString();
            parameters["offset"]  = offset.ToString();
            parameters["count"]   = count.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <List <AudioObj> >("audio.getRecommendations", parameters, callback, AudioService._deserializeAudioList, false, true, new CancellationToken?(), null);
        }
Beispiel #8
0
        public void GetBannedUsers(int offset, int count, Action <BackendResult <VKList <User>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["offset"] = offset.ToString();
            parameters["count"]  = count.ToString();
            parameters["fields"] = "photo_max";
            VKRequestsDispatcher.DispatchRequestToVK <VKList <User> >("account.getBanned", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
        public void GetFaveVideos(int offset, int count, Action <BackendResult <VKList <Video>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["offset"]   = offset.ToString();
            parameters["count"]    = count.ToString();
            parameters["extended"] = "1";
            VKRequestsDispatcher.DispatchRequestToVK <VKList <Video> >("fave.getVideos", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
        public void SearchTracks(string query, int offset, int count, Action <BackendResult <VKList <AudioObj>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["q"]          = query;
            parameters["count"]      = count.ToString();
            parameters["offset"]     = offset.ToString();
            parameters["search_own"] = "1";
            VKRequestsDispatcher.DispatchRequestToVK <VKList <AudioObj> >("audio.search", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Beispiel #11
0
 public void ResolveScreenName(string name, Action <BackendResult <ResolvedData, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <ResolvedData>("execute.resolveScreenName", new Dictionary <string, string>()
     {
         {
             "name",
             name
         }
     }, callback, null, false, true, new CancellationToken?(), null);
 }
Beispiel #12
0
        public void InternalGetNotifications(string device, string os, string appVersion, string locale, Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["device"]      = device;
            parameters["os"]          = os;
            parameters["app_version"] = appVersion;
            parameters["locale"]      = locale;
            VKRequestsDispatcher.DispatchRequestToVK <VKClient.Common.Backend.DataObjects.ResponseWithId>("internal.getNotifications", parameters, callback, (Func <string, VKClient.Common.Backend.DataObjects.ResponseWithId>)(jsonStr => new VKClient.Common.Backend.DataObjects.ResponseWithId()), false, true, new CancellationToken?(), null);
        }
 /*
  * [Obsolete("Method is deprecated. Use validationSid", false)]
  * public void SendSMS(string userId, string password, Action<BackendResult<AutorizationData, ResultCode>> callbackAction)
  * {
  * VKRequestsDispatcher.DispatchLoginRequest(userId, password, "", true, callbackAction, new CancellationToken?());
  * }
  */
 public void SendSMS(string validationSid, Action <BackendResult <int, ResultCode> > callbackAction)
 {
     VKRequestsDispatcher.DispatchRequestToVK <int>("auth.validatePhone", new Dictionary <string, string>()
     {
         {
             "sid",
             validationSid
         }
     }, callbackAction, null, false, true, new CancellationToken?(), null);
 }
Beispiel #14
0
 public void SetStatusText(string text, Action <BackendResult <object, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <object>("status.set", new Dictionary <string, string>()
     {
         {
             "text",
             text
         }
     }, callback, null, false, true, new CancellationToken?(), null);
 }
Beispiel #15
0
        public void Search(string searchStr, int offset, int count, Action <BackendResult <VKList <Group>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["q"]      = searchStr;
            parameters["offset"] = offset.ToString();
            parameters["count"]  = count.ToString();
            parameters["fields"] = "start_date";
            VKRequestsDispatcher.DispatchRequestToVK <VKList <Group> >("groups.search", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Beispiel #16
0
 public void DeleteFriend(long userId, Action <BackendResult <OwnCounters, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <OwnCounters>("execute", new Dictionary <string, string>()
     {
         {
             "code",
             string.Format("var uid = {0};\r\n\r\nAPI.friends.delete({{\"user_id\": uid}});\r\n\r\nreturn API.getCounters();", userId)
         }
     }, callback, new Func <string, OwnCounters>(CountersDeserializerHelper.Deserialize), false, true, new CancellationToken?(), null);
 }
Beispiel #17
0
        public void GetProfileInfo(long userId, Action <BackendResult <UserData, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            /*
             * parameters["userId"] = userId.ToString();
             * parameters["func_v"] = "3";
             * VKRequestsDispatcher.DispatchRequestToVK<UserData>("execute.getProfileInfo", parameters, callback, (Func<string, UserData>)(jsonStr =>
             * {
             *  jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "relatives", false);
             *  jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "wallData", true);
             *  jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Groups", false);
             *  jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "personal");
             *  jsonStr = VKRequestsDispatcher.FixArrayToObject(jsonStr, "occupation");
             *  jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "photos", true);
             *  jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "subscriptions", true);
             *  jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "gifts", true);
             *  int resultCount;
             *  jsonStr = VKRequestsDispatcher.GetArrayCountAndRemove(jsonStr, "wall", out resultCount);
             *  VKRequestsDispatcher.GenericRoot<UserData> genericRoot = JsonConvert.DeserializeObject<VKRequestsDispatcher.GenericRoot<UserData>>(jsonStr);
             *  if (genericRoot.response.user.counters.docs == 0)
             *      genericRoot.response.user.counters.docs = genericRoot.response.docsCount;
             *  return genericRoot.response;
             * }), false, true, new CancellationToken?(), null);*/
            parameters["user_id"]     = userId.ToString();
            parameters["func_v"]      = "2";
            parameters["photo_count"] = "25";
            parameters["gift_count"]  = "25";
            parameters["photo_sizes"] = "1";
            parameters["skip_hidden"] = "1";

            Action <BackendResult <User, ResultCode> > act = (ud) =>
            {
                BackendResult <UserData, ResultCode> res = new BackendResult <UserData, ResultCode>();
                res.ResultData        = new UserData();
                res.ResultData.user   = ud.ResultData;
                res.ResultData.gifts  = ud.ResultData.gifts;
                res.ResultData.photos = ud.ResultData.photos;
                res.ResultCode        = ResultCode.Succeeded;
                callback(res);
            };

            VKRequestsDispatcher.DispatchRequestToVK <User>("execute.getFullProfileNewNew", parameters, act, (Func <string, User>)(jsonStr =>
            {
                //"status":{"text":"На пути достижения цели..."}
                Regex r     = new Regex(".+(\"status\":{\"text\":\"(.*?)\"})");
                Match m     = r.Match(jsonStr);
                string str1 = m.Groups[1].Value;
                string str2 = m.Groups[2].Value;
                jsonStr     = jsonStr.Replace(str1, "\"status\":\"" + str2 + "\"");

                VKRequestsDispatcher.GenericRoot <User> genericRoot = JsonConvert.DeserializeObject <VKRequestsDispatcher.GenericRoot <User> >(jsonStr);
                return(genericRoot.response);
            }), false, true, new CancellationToken?(), null);
        }
Beispiel #18
0
        public void GetFriendRequests(Action <BackendResult <FriendRequestsMaterial, ResultCode> > callback)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary["func_v"] = "3";
            dictionary["count"]  = "10";
            dictionary["fields"] = "online,photo_50,photo_100,photo_200";
            CancellationToken?cancellationToken = new CancellationToken?();

            VKRequestsDispatcher.DispatchRequestToVK <FriendRequestsMaterial>("execute.getFriendRequestsMaterial", dictionary, callback, (Func <string, FriendRequestsMaterial>)(jsonString => JsonConvert.DeserializeObject <GenericRoot <FriendRequestsMaterial> >(jsonString).response), false, true, cancellationToken, null);
        }
Beispiel #19
0
        public void GetNotifications(int startTime, int endTime, int offset, string fromStr, int count, Action <BackendResult <NotificationData, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (startTime > 0)
            {
                parameters["start_time"] = startTime.ToString();
            }
            if (endTime > 0)
            {
                parameters["end_time"] = endTime.ToString();
            }
            if (count > 0)
            {
                parameters["count"] = count.ToString();
            }
            if (offset > 0)
            {
                parameters["offset"] = offset.ToString();
            }
            if (!string.IsNullOrWhiteSpace(fromStr))
            {
                parameters["start_from"] = fromStr;
            }
            parameters["fields"] = "sex,photo_50,photo_100,online,screen_name,first_name_dat,last_name_dat,first_name_gen,last_name_gen";
            Dictionary <string, string> dictionary = parameters;

            dictionary["fields"] = dictionary["fields"] + ",is_closed,type,is_admin,is_member,photo_200";
            VKRequestsDispatcher.DispatchRequestToVK <NotificationData>("notifications.get", parameters, callback, (Func <string, NotificationData>)(jsonStr =>
            {
                int resultCount                      = 0;
                jsonStr                              = VKRequestsDispatcher.GetArrayCountAndRemove(jsonStr, "items", out resultCount);
                jsonStr                              = VKRequestsDispatcher.FixFalseArray(jsonStr, "profiles", false);
                jsonStr                              = VKRequestsDispatcher.FixFalseArray(jsonStr, "groups", false);
                NotificationData response            = JsonConvert.DeserializeObject <GenericRoot <NotificationData> >(jsonStr).response;
                response.TotalCount                  = resultCount;
                List <Notification> notificationList = new List <Notification>();
                foreach (Notification notification in response.items)
                {
                    notification.UpdateNotificationType();
                    object parsedFeedback = notification.ParsedFeedback;
                    object parsedParent   = notification.ParsedParent;
                    if (notification.NotType == NotificationType.unknown)
                    {
                        notificationList.Add(notification);
                    }
                }
                foreach (Notification notification in notificationList)
                {
                    response.items.Remove(notification);
                }
                return(response);
            }), false, true, new CancellationToken?(), null);
        }
Beispiel #20
0
        public void DeleteAlbum(string aid, Action <BackendResult <ResponseWithId, ResultCode> > callback, long gid = 0)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["album_id"] = aid;
            if (gid != 0L)
            {
                parameters["group_id"] = gid.ToString();
            }
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("photos.deleteAlbum", parameters, callback, (Func <string, ResponseWithId>)(jsonstr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Beispiel #21
0
        private void GetPhotoUploadServerAlbum(string aid, long optionalGroupId, Action <BackendResult <UploadServerAddress, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["album_id"] = aid;
            if (optionalGroupId != 0L)
            {
                parameters["group_id"] = optionalGroupId.ToString();
            }
            VKRequestsDispatcher.DispatchRequestToVK <UploadServerAddress>("photos.getUploadServer", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Beispiel #22
0
        public void DeletePhoto(long pid, long ownerId, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["photo_id"] = pid.ToString();
            if (ownerId != 0L)
            {
                parameters["owner_id"] = ownerId.ToString();
            }
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("photos.delete", parameters, callback, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Beispiel #23
0
        private void GetPhotoUploadServerWall(long userOrGroupId, bool isGroup, Action <BackendResult <UploadServerAddress, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            if (userOrGroupId != 0L)
            {
                string index = isGroup ? "group_id" : "user_id";
                parameters[index] = userOrGroupId.ToString();
            }
            VKRequestsDispatcher.DispatchRequestToVK <UploadServerAddress>("photos.getWallUploadServer", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Beispiel #24
0
        public void GetFollowers(long uid, int offset, Action <BackendResult <List <User>, ResultCode> > callback)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary["user_id"] = uid.ToString();
            dictionary["offset"]  = offset.ToString();
            dictionary["fields"]  = "online, online_mobile,photo_max";
            CancellationToken?cancellationToken = new CancellationToken?();

            VKRequestsDispatcher.DispatchRequestToVK <List <User> >("users.getFollowers", dictionary, callback, (Func <string, List <User> >)(jsonStr => JsonConvert.DeserializeObject <GenericRoot <VKList <User> > >(jsonStr).response.items), false, true, cancellationToken, null);
        }
Beispiel #25
0
        public void DeleteAlbum(long albumId, Action <BackendResult <object, ResultCode> > callback, long?groupId = null)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["album_id"] = albumId.ToString();
            if (groupId.HasValue && groupId.Value > 0L)
            {
                parameters["group_id"] = groupId.Value.ToString();
            }
            VKRequestsDispatcher.DispatchRequestToVK <object>("video.deleteAlbum", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Beispiel #26
0
        public void MoveVideoToAlbum(List <long> videoIds, long albumId, Action <BackendResult <object, ResultCode> > callback, long?groupId = null)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["vids"]     = videoIds.GetCommaSeparated();
            parameters["album_id"] = albumId.ToString();
            if (groupId.HasValue)
            {
                parameters["group_id"] = groupId.Value.ToString();
            }
            VKRequestsDispatcher.DispatchRequestToVK <object>("video.moveToAlbum", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Beispiel #27
0
        public void EditList(long lid, string name, List <long> uids, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["name"]    = name;
            parameters["list_id"] = lid.ToString();
            if (!uids.IsNullOrEmpty())
            {
                parameters["user_ids"] = uids.GetCommaSeparated();
            }
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("friends.editList", parameters, callback, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Beispiel #28
0
        public void UploadVideo(Stream stream, bool isPrivate, long albumId, long groupId, string name, string description, Action <BackendResult <SaveVideoResponse, ResultCode> > callback, Action <double> progressCallback = null, Cancellation c = null, PrivacyInfo privacyViewInfo = null, PrivacyInfo privacyCommentInfo = null)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["is_private"] = isPrivate ? "1" : "0";
            if (groupId != 0L)
            {
                parameters["group_id"] = groupId.ToString();
            }
            if (albumId != 0L)
            {
                parameters["album_id"] = albumId.ToString();
            }
            if (!string.IsNullOrEmpty(name))
            {
                parameters["name"] = name;
            }
            if (!string.IsNullOrEmpty(description))
            {
                parameters["description"] = description;
            }
            if (privacyViewInfo != null && groupId == 0L)
            {
                parameters["privacy_view"] = privacyViewInfo.ToString();
            }
            if (privacyCommentInfo != null && groupId == 0L)
            {
                parameters["privacy_comment"] = privacyCommentInfo.ToString();
            }
            VKRequestsDispatcher.DispatchRequestToVK <SaveVideoResponse>("video.save", parameters, (Action <BackendResult <SaveVideoResponse, ResultCode> >)(res =>
            {
                if (res.ResultCode != ResultCode.Succeeded)
                {
                    callback(new BackendResult <SaveVideoResponse, ResultCode>(res.ResultCode));
                }
                else
                {
                    SaveVideoResponse svr = res.ResultData;
                    JsonWebRequest.Upload(svr.upload_url, stream, "video_file", "video", (Action <JsonResponseData>)(uploadRes =>
                    {
                        if (uploadRes.IsSucceeded)
                        {
                            callback(new BackendResult <SaveVideoResponse, ResultCode>(ResultCode.Succeeded, svr));
                        }
                        else
                        {
                            callback(new BackendResult <SaveVideoResponse, ResultCode>(ResultCode.UnknownError));
                        }
                    }), null, progressCallback, c);
                }
            }), null, false, true, new CancellationToken?(), null);
        }
Beispiel #29
0
        public void EditComment(long cid, string text, long ownerId, List <string> attachmentIds, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["comment_id"] = cid.ToString();
            parameters["message"]    = text;
            parameters["owner_id"]   = ownerId.ToString();
            if (!attachmentIds.IsNullOrEmpty())
            {
                parameters["attachments"] = attachmentIds.GetCommaSeparated(",");
            }
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("photos.editComment", parameters, callback, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Beispiel #30
0
        public void CreatePoll(string question, bool isAnonymous, long ownerId, List <string> answers, Action <BackendResult <Poll, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["question"]     = question;
            parameters["is_anonymous"] = isAnonymous ? "1" : "0";
            if (ownerId != 0L)
            {
                parameters["owner_id"] = ownerId.ToString();
            }
            parameters["add_answers"] = "[" + answers.Select <string, string>((Func <string, string>)(a => "\"" + a + "\"")).ToList <string>().GetCommaSeparated(",") + "]";
            VKRequestsDispatcher.DispatchRequestToVK <Poll>("polls.create", parameters, callback, null, false, true, new CancellationToken?(), null);
        }