Пример #1
0
        public void SetShortName(string shortName, Action <BackendResult <SaveProfileResponse, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["screen_name"] = shortName;
            VKRequestsDispatcher.DispatchRequestToVK <SaveProfileResponse>("account.saveProfileInfo", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #2
0
        public static void Execute <T>(string code, Action <BackendResult <T, ResultCode> > callback, Func <string, T> customDesFunc = null, bool lowPriority = false, bool pageDataRequest = true, CancellationToken?cancellationToken = null) where T : class
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["code"] = code;
            VKRequestsDispatcher.DispatchRequestToVK <T>("execute", parameters, callback, customDesFunc, lowPriority, pageDataRequest, cancellationToken, null);
        }
Пример #3
0
 private static void ProcessValidationResponse <R>(ValidationUserResponse valResp, string baseUrl, string methodName, Dictionary <string, string> parameters, Action <BackendResult <R, ResultCode> > callback, Func <string, R> customDeserializationFunc = null, bool lowPriority = false, bool pageDataRequest = true, CancellationToken?cancellationToken = null)
 {
     if (valResp.IsSucceeded)
     {
         int num = !string.IsNullOrEmpty(AppGlobalStateManager.Current.GlobalState.AccessToken) ? 1 : 0;
         if (!string.IsNullOrEmpty(valResp.access_token))
         {
             VKRequestsDispatcher._autorizationData.access_token   = valResp.access_token;
             AppGlobalStateManager.Current.GlobalState.AccessToken = valResp.access_token;
         }
         if (num != 0)
         {
             VKRequestsDispatcher.DoDispatch <R>(baseUrl, methodName, parameters, callback, customDeserializationFunc, lowPriority, pageDataRequest, cancellationToken, null);
         }
         else
         {
             string str = string.Format("{{\"access_token\":\"{0}\",\"user_id\":{1} }} ", valResp.access_token, valResp.user_id);
             R      r   = customDeserializationFunc(str);
             VKRequestsDispatcher.InvokeCallback((Action)(() => callback(new BackendResult <R, ResultCode>(ResultCode.Succeeded, r))), cancellationToken);
         }
     }
     else
     {
         VKRequestsDispatcher.InvokeCallback((Action)(() => callback(new BackendResult <R, ResultCode>(ResultCode.ValidationCancelledOrFailed))), cancellationToken);
     }
 }
Пример #4
0
        public void SetCommunityInformation(long id, string name, string description, long category, long subcategory, string site, int accessLevel, string domain, int ageLimits, string foundationDate, long?eventOrganizerId, string eventOrganizerPhone, string eventOrganizerEmail, int eventStartDate, int eventFinishDate, Action <BackendResult <int, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>()
            {
                {
                    "group_id",
                    id.ToString()
                },
                {
                    "title",
                    name
                },
                {
                    "description",
                    description
                },
                {
                    "subject",
                    category.ToString()
                },
                {
                    "public_category",
                    category.ToString()
                },
                {
                    "public_subcategory",
                    subcategory.ToString()
                },
                {
                    "website",
                    site
                },
                {
                    "access",
                    accessLevel.ToString()
                },
                {
                    "age_limits",
                    ageLimits.ToString()
                }
            };

            if (domain != null)
            {
                parameters.Add("screen_name", domain);
            }
            if (foundationDate != null)
            {
                parameters.Add("public_date", foundationDate);
            }
            if (eventOrganizerId.HasValue)
            {
                parameters.Add("event_group_id", eventOrganizerId.Value.ToString());
                parameters.Add("phone", eventOrganizerPhone);
                parameters.Add("email", eventOrganizerEmail);
                parameters.Add("event_start_date", eventStartDate.ToString());
                parameters.Add("event_finish_date", eventFinishDate.ToString());
            }
            VKRequestsDispatcher.DispatchRequestToVK <int>("groups.edit", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #5
0
        public void SearchSubscribers(string q, long communityId, int offset, int count, bool isFriendsOnly, Action <BackendResult <VKList <User>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>()
            {
                {
                    "q",
                    q
                },
                {
                    "offset",
                    offset.ToString()
                },
                {
                    "count",
                    count.ToString()
                },
                {
                    "group_id",
                    communityId.ToString()
                },
                {
                    "fields",
                    "online,online_mobile,photo_max"
                }
            };

            if (isFriendsOnly)
            {
                parameters.Add("from_list", "friends");
            }
            VKRequestsDispatcher.DispatchRequestToVK <VKList <User> >("users.search", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #6
0
        public void RemoveList(long lid, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["list_id"] = lid.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("friends.deleteList", parameters, callback, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Пример #7
0
        public void GetCatalog(int categoryId, Action <BackendResult <VKList <Group>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["category_id"] = categoryId.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <VKList <Group> >("groups.getCatalog", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #8
0
        public void AddRemovedToFromAlbum(bool add, long targetId, long album_id, long owner_id, long video_id, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["target_id"] = targetId.ToString();
            parameters["album_id"]  = album_id.ToString();
            parameters["owner_id"]  = owner_id.ToString();
            parameters["video_id"]  = video_id.ToString();
            string methodName = add ? "video.addToAlbum" : "video.removeFromAlbum";

            if (add && album_id == VideoAlbum.ADDED_ALBUM_ID)
            {
                methodName = "video.add";
            }
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>(methodName, parameters, (Action <BackendResult <ResponseWithId, ResultCode> >)(res =>
            {
                if (res.ResultCode == ResultCode.Succeeded)
                {
                    EventAggregator current             = EventAggregator.Current;
                    VideoAddedDeleted videoAddedDeleted = new VideoAddedDeleted();
                    int num1 = add ? 1 : 0;
                    videoAddedDeleted.IsAdded = num1 != 0;
                    long num2 = video_id;
                    videoAddedDeleted.VideoId = num2;
                    long num3 = owner_id;
                    videoAddedDeleted.OwnerId = num3;
                    long num4 = targetId;
                    videoAddedDeleted.TargetId = num4;
                    long num5 = album_id;
                    videoAddedDeleted.AlbumId = num5;
                    current.Publish(videoAddedDeleted);
                }
                callback(res);
            }), (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Пример #9
0
        public void HideCatalogSection(int sectionId, Action <BackendResult <ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["section_id"] = sectionId.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>("video.hideCatalogSection", parameters, callback, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), false, true, new CancellationToken?(), null);
        }
Пример #10
0
        public void CreateAlbum(string albumName, Action <BackendResult <AudioAlbum, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["title"] = albumName;
            VKRequestsDispatcher.DispatchRequestToVK <AudioAlbum>("audio.addAlbum", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #11
0
        public void GetVideos(long userOrGroupId, bool isGroup, int offset, int count, Action <BackendResult <VKList <Video>, ResultCode> > callback, long albumId = 0, bool extended = true)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            if (isGroup)
            {
                dictionary["group_id"] = userOrGroupId.ToString();
            }
            else
            {
                dictionary["user_id"] = userOrGroupId.ToString();
            }
            if (albumId != 0L)
            {
                dictionary["album_id"] = albumId.ToString();
            }
            dictionary["offset"]   = offset.ToString();
            dictionary["count"]    = count.ToString();
            dictionary["extended"] = extended ? "1" : "0";
            string methodName = "video.get";
            Dictionary <string, string> parameters = dictionary;
            Action <BackendResult <VKList <Video>, ResultCode> > callback1 = callback;
            int num1 = 0;
            int num2 = 1;
            CancellationToken?cancellationToken = new CancellationToken?();

            // ISSUE: variable of the null type

            VKRequestsDispatcher.DispatchRequestToVK <VKList <Video> >(methodName, parameters, callback1, (Func <string, VKList <Video> >)(jsonStr => JsonConvert.DeserializeObject <GenericRoot <VKList <Video> > >(jsonStr).response), num1 != 0, num2 != 0, cancellationToken, null);
        }
Пример #12
0
        public void DeleteAlbum(long albumId, Action <BackendResult <object, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["album_id"] = albumId.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <object>("audio.deleteAlbum", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #13
0
        public void GetLyrics(long lyrics_id, Action <BackendResult <Lyrics, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["lyrics_id"] = lyrics_id.ToString();
            VKRequestsDispatcher.DispatchRequestToVK <Lyrics>("audio.getLyrics", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #14
0
        public void GetAudio(List <string> ids, Action <BackendResult <List <AudioObj>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["audios"] = ids.GetCommaSeparated(",");
            VKRequestsDispatcher.DispatchRequestToVK <List <AudioObj> >("audio.getById", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #15
0
        private void IgnoreUnignoreItem(bool ignore, string type, long ownerId, long itemId, Action <BackendResult <bool, ResultCode> > callback)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();
            string index1 = "type";
            string str1   = type;

            dictionary[index1] = str1;
            string index2 = "owner_id";
            string str2   = ownerId.ToString();

            dictionary[index2] = str2;
            string index3 = "item_id";
            string str3   = itemId.ToString();

            dictionary[index3] = str3;
            Dictionary <string, string> parameters = dictionary;

            VKRequestsDispatcher.DispatchRequestToVK <bool>(ignore ? "newsfeed.ignoreItem" : "newsfeed.unignoreItem", parameters, callback, (Func <string, bool>)(jsonStr =>
            {
                VKRequestsDispatcher.GenericRoot <int> genericRoot = JsonConvert.DeserializeObject <VKRequestsDispatcher.GenericRoot <int> >(jsonStr);
                if (genericRoot == null)
                {
                    return(false);
                }
                return(genericRoot.response == 1);
            }), false, true, new CancellationToken?(), null);
        }
Пример #16
0
        public void GetVideoCatalogSection(string categoryId, string fromStr, Action <BackendResult <GetCatalogSectionResponse, ResultCode> > callback)
        {
            if (string.IsNullOrWhiteSpace(fromStr))
            {
                callback(new BackendResult <GetCatalogSectionResponse, ResultCode>(ResultCode.Succeeded, new GetCatalogSectionResponse()));
            }
            else
            {
                Dictionary <string, string> dictionary = new Dictionary <string, string>();
                dictionary["extended"]   = "1";
                dictionary["section_id"] = categoryId;
                dictionary["from"]       = fromStr ?? "";
                dictionary["count"]      = "16";
                dictionary["fields"]     = "members_count";
                string methodName = "video.getCatalogSection";
                Dictionary <string, string> parameters = dictionary;
                Action <BackendResult <GetCatalogSectionResponse, ResultCode> > callback1 = callback;
                int num1 = 0;
                int num2 = 1;
                CancellationToken?cancellationToken = new CancellationToken?();
                // ISSUE: variable of the null type

                VKRequestsDispatcher.DispatchRequestToVK <GetCatalogSectionResponse>(methodName, parameters, callback1, (Func <string, GetCatalogSectionResponse>)(jsonStr => JsonConvert.DeserializeObject <GenericRoot <GetCatalogSectionResponse> >(jsonStr).response), num1 != 0, num2 != 0, cancellationToken, null);
            }
        }
Пример #17
0
 public void GetUsersNoCache(List <int> userIds, Action <BackendResult <List <User>, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <List <User> >("users.get", new Dictionary <string, string>()
     {
         {
             "user_ids",
             userIds.GetCommaSeparated()
         },
         {
             "fields",
             "uid,first_name,last_name,online,online_mobile,photo_max,sex,photo_medium,friend_status"
         }
     }, (Action <BackendResult <List <User>, ResultCode> >)(res =>
     {
         if (res.ResultCode == ResultCode.Succeeded)
         {
             foreach (User user in res.ResultData)
             {
                 user.CachedDateTime        = DateTime.Now;
                 this._usersCache[user.uid] = user;
             }
         }
         callback(res);
     }), null, false, true, new CancellationToken?(), null);
 }
Пример #18
0
        public void SignUp(string phone, string firstName, string lastName, bool voice, bool isMale, string sid, Action <BackendResult <string, ResultCode> > callbackAction)
        {
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary.Add("phone", phone);
            dictionary.Add("first_name", firstName);
            dictionary.Add("last_name", lastName);
            dictionary.Add("client_id", VKConstants.ApplicationID);
            dictionary.Add("client_secret", VKConstants.ApplicationSecretKey);
            dictionary["voice"] = voice ? "1" : "0";
            dictionary["sex"]   = isMale ? "2" : "1";
            if (SignUpService.TestMode)
            {
                dictionary["test_mode"] = "1";
            }
            if (!string.IsNullOrEmpty(sid))
            {
                dictionary.Add("sid", sid);
            }
            string methodName = "auth.signup";
            Dictionary <string, string> parameters = dictionary;
            Action <BackendResult <string, ResultCode> > callback = callbackAction;
            int num1 = 0;
            int num2 = 1;
            CancellationToken?cancellationToken = new CancellationToken?();

            // ISSUE: variable of the null type

            VKRequestsDispatcher.DispatchRequestToVK <string>(methodName, parameters, callback, (Func <string, string>)(jsonStr => JsonConvert.DeserializeObject <KeyValuePair <string, string> >(jsonStr).Value), num1 != 0, num2 != 0, cancellationToken, null);
        }
Пример #19
0
        public void GetNearby(double lat, double lon, uint?accuracy, Action <BackendResult <VKList <User>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>()
            {
                {
                    "latitude",
                    lat.ToString((IFormatProvider)CultureInfo.InvariantCulture)
                },
                {
                    "longitude",
                    lon.ToString((IFormatProvider)CultureInfo.InvariantCulture)
                },
                {
                    "radius",
                    "2"
                },
                {
                    "timeout",
                    "300"
                },
                {
                    "fields",
                    "photo_max,verified,occupation,city,country,friend_status,common_count"
                }
            };

            if (accuracy.HasValue)
            {
                parameters["accuracy"] = accuracy.Value.ToString((IFormatProvider)CultureInfo.InvariantCulture);
            }
            VKRequestsDispatcher.DispatchRequestToVK <VKList <User> >("users.getNearby", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #20
0
        public void AddRemoveLike(bool add, long owner_id, long item_id, LikeObjectType objectType, Action <BackendResult <ResponseWithId, ResultCode> > callback, string accessKey = "")
        {
            string methodName = add ? "likes.add" : "likes.delete";
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary["owner_id"] = owner_id.ToString();
            dictionary["item_id"]  = item_id.ToString();
            dictionary["type"]     = objectType.ToString();
            if (!string.IsNullOrEmpty(accessKey))
            {
                dictionary["access_key"] = accessKey;
            }
            EventAggregator.Current.Publish(new ObjectLikedUnlikedEvent()
            {
                Liked       = add,
                ItemId      = item_id,
                OwnerId     = owner_id,
                LikeObjType = objectType
            });
            Dictionary <string, string> parameters = dictionary;
            Action <BackendResult <ResponseWithId, ResultCode> > callback1 = (Action <BackendResult <ResponseWithId, ResultCode> >)(res =>
            {
                int resultCode = (int)res.ResultCode;
                callback(res);
            });
            int num1 = 0;
            int num2 = 1;
            CancellationToken?cancellationToken = new CancellationToken?();

            // ISSUE: variable of the null type

            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>(methodName, parameters, callback1, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), num1 != 0, num2 != 0, cancellationToken, null);
        }
Пример #21
0
        public void GetCatalogCategoriesPreview(Action <BackendResult <GroupCatalogInfoExtended, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["extended"] = "1";
            VKRequestsDispatcher.DispatchRequestToVK <GroupCatalogInfoExtended>("groups.getCatalogInfo", parameters, callback, null, false, true, new CancellationToken?(), null);
        }
Пример #22
0
        public void GetPhotoWithFullInfo(long ownerId, long pid, string accessKey, int knownCommentsCount, int offset, int commentsCountToRead, Action <BackendResult <PhotoWithFullInfo, ResultCode> > callback)
        {
            string str1 = ownerId.ToString() + "_" + pid;

            if (!string.IsNullOrWhiteSpace(accessKey))
            {
                str1 = str1 + "_" + accessKey;
            }
            string str2 = string.Format("var ownerId = {0};\r\n\r\nvar pid  = {1};\r\n\r\n\r\nvar commentsCount = {2};\r\n\r\nvar offset = {3};\r\n\r\nvar countToRead = {4};\r\n\r\nvar likesAll = API.likes.getList({{ \"type\": \"photo\", \"owner_id\":ownerId, \"item_id\":pid, \"count\":10}}).items;\r\n\r\nvar photo = API.photos.getById({{\"photos\" : \"{6}\", \"extended\":1 }});\r\n\r\nif (commentsCount == -1)\r\n{{\r\n   commentsCount = photo[0].comments.count;   \r\n}}\r\n\r\nvar calculatedOffset = commentsCount - offset - countToRead;\r\n\r\nif (calculatedOffset < 0)\r\n{{\r\n   calculatedOffset = 0;\r\n}}\r\nvar comments = API.photos.getComments({{ \"photo_id\" : pid, \"owner_id\": ownerId, \"offset\":calculatedOffset,  \"count\":countToRead, \"sort\":\"asc\", \"need_likes\":1, \"access_key\":\"{5}\", \"allow_group_comments\":1 }});\r\n\r\n\r\nvar users2 = API.users.get({{ \"user_ids\":[email protected]_to_user, \"fields\":\"first_name_dat,last_name_dat\"}});\r\n\r\n\r\n\r\nvar photoTags = API.photos.getTags({{\"owner_id\":ownerId, \"photo_id\":pid, \"access_key\":\"{5}\"}});\r\n\r\nvar userOrGroupIds = [];\r\n\r\nvar repostsCount = 0;\r\nif(likesAll+\"\"!=\"\")\r\n{{\r\n  repostsCount =  API.likes.getList({{ \"type\": \"photo\", \"owner_id\":ownerId, \"item_id\":pid, \"filter\":\"copies\"}}).count;\r\n  userOrGroupIds = likesAll;\r\n}}\r\n\r\nif (commentsCount>0)\r\n{{\r\n    userOrGroupIds = userOrGroupIds + [email protected]_id;\r\n}}\r\n\r\nvar userIds = [];\r\nvar groupIds = [];\r\n\r\nvar i = 0;\r\n\r\nif (ownerId < 0)\r\n{{\r\n     var negOwner = -ownerId;\r\n     groupIds = groupIds + negOwner;\r\n\r\n     if (photo[0].user_id != 0 && photo[0].user_id != 100)\r\n     {{\r\n         userIds = userIds + photo[0].user_id;\r\n     }}\r\n}}\r\nelse\r\n{{\r\n    userIds = userIds + ownerId;\r\n}}\r\n\r\nvar length = userOrGroupIds.length;\r\n\r\nwhile (i < length)\r\n{{\r\n    var id = parseInt(userOrGroupIds[i]);\r\n    \r\n    if (id > 0)\r\n    {{\r\n       if (userIds.length > 0)\r\n       {{\r\n          userIds = userIds + \",\";\r\n       }}\r\n       userIds = userIds + id;\r\n    }}\r\n    else if (id < 0)\r\n    {{\r\n        id = -id;\r\n        if (groupIds.length > 0)\r\n        {{\r\n            groupIds = groupIds + \",\";\r\n        }}\r\n        groupIds = groupIds + id;\r\n    }}\r\n     \r\n    i = i + 1;\r\n}}\r\n\r\nvar users  = API.users.get({{\"user_ids\":userIds, \"fields\":\"sex,photo_max,online,online_mobile\" }});\r\nvar users3 =API.users.get({{\"user_ids\":userIds, \"fields\":\"first_name_dat,last_name_dat\" }}); \r\nvar groups = API.groups.getById({{\"group_ids\":groupIds}});\r\n\r\n\r\n\r\nreturn {{\"Photo\":photo[0], \"comments\": comments, \"LikesAllIds\":likesAll, \"Users\":users, \r\n\"Groups\":groups, \"Users2\":users2, \"Users3\": users3, \"PhotoTags\": photoTags, \"RepostsCount\":repostsCount}};", ownerId, pid, knownCommentsCount, offset, commentsCountToRead, accessKey, str1);
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["code"] = str2;
            VKRequestsDispatcher.DispatchRequestToVK <PhotoWithFullInfo>("execute", parameters, callback, (Func <string, PhotoWithFullInfo>)(jsonStr =>
            {
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "comments", true);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Users", false);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Users2", false);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Users3", false);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "Groups", false);
                jsonStr = VKRequestsDispatcher.FixFalseArray(jsonStr, "PhotoTags", false);
                PhotoWithFullInfo response = JsonConvert.DeserializeObject <VKRequestsDispatcher.GenericRoot <PhotoWithFullInfo> >(jsonStr).response;
                response.Users2.AddRange((IEnumerable <User>)response.Users3);
                GroupsService.Current.AddCachedGroups((IEnumerable <Group>)response.Groups);
                foreach (Comment comment in response.Comments)
                {
                    string message = comment.message;
                    comment.text   = message;
                }
                if (response.LikesAllIds == null)
                {
                    response.LikesAllIds = new List <long>();
                }
                return(response);
            }), false, true, new CancellationToken?(), null);
        }
Пример #23
0
 public void BlockUser(long communityId, long userId, int durationUnixTime, int reason, string comment, bool isCommentVisible, Action <BackendResult <int, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <int>("groups.banUser", new Dictionary <string, string>()
     {
         {
             "group_id",
             communityId.ToString()
         },
         {
             "user_id",
             userId.ToString()
         },
         {
             "end_date",
             durationUnixTime.ToString()
         },
         {
             "reason",
             reason.ToString()
         },
         {
             "comment",
             comment
         },
         {
             "comment_visible",
             isCommentVisible ? "1" : "0"
         }
     }, callback, null, false, true, new CancellationToken?(), null);
 }
Пример #24
0
        public void DeleteAlbums(List <string> aids, long gid = 0)
        {
            string empty  = string.Empty;
            string format = gid != 0L ? "API.photos.deleteAlbum({{\"album_id\":\"{0}\", \"group_id\":{1}}});" + Environment.NewLine : "API.photos.deleteAlbum({{\"album_id\":\"{0}\"}});" + Environment.NewLine;
            string str    = "";

            foreach (string aid in aids)
            {
                str = gid != 0L ? str + string.Format(format, aid, gid) : str + string.Format(format, aid);
            }
            Dictionary <string, string> dictionary = new Dictionary <string, string>();

            dictionary["code"] = str;
            string methodName = "execute";
            Dictionary <string, string> parameters = dictionary;
            Action <BackendResult <ResponseWithId, ResultCode> > action = (Action <BackendResult <ResponseWithId, ResultCode> >)(res => {});
            int num1 = 0;
            int num2 = 1;
            CancellationToken?cancellationToken = new CancellationToken?();
            // ISSUE: variable of the null type

            Action <BackendResult <ResponseWithId, ResultCode> > callback = (Action <BackendResult <ResponseWithId, ResultCode> >)(res => { });

            VKRequestsDispatcher.DispatchRequestToVK <ResponseWithId>(methodName, parameters, callback, (Func <string, ResponseWithId>)(jsonStr => new ResponseWithId()), num1 != 0, num2 != 0, cancellationToken, null);
        }
Пример #25
0
 public void SetCommunityPlacement(long communityId, long countryId, long cityId, string address, string title, double latitude, double longitude, Action <BackendResult <PlacementEditingResult, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <PlacementEditingResult>("groups.editPlace", new Dictionary <string, string>()
     {
         {
             "group_id",
             communityId.ToString()
         },
         {
             "country_id",
             countryId.ToString()
         },
         {
             "city_id",
             cityId.ToString()
         },
         {
             "address",
             address
         },
         {
             "title",
             title
         },
         {
             "latitude",
             latitude.ToString((IFormatProvider)CultureInfo.InvariantCulture)
         },
         {
             "longitude",
             longitude.ToString((IFormatProvider)CultureInfo.InvariantCulture)
         }
     }, callback, null, false, true, new CancellationToken?(), null);
 }
Пример #26
0
        public void GetPhotos(long userOrGroupId, bool isGroup, string aid, List <long> pids, long feed, string feedType, Action <BackendResult <List <Photo>, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["owner_id"] = isGroup ? (-userOrGroupId).ToString() : userOrGroupId.ToString();
            parameters["album_id"] = aid;
            if (!pids.IsNullOrEmpty())
            {
                parameters["photo_ids"] = pids.GetCommaSeparated();
            }
            parameters["extended"] = "1";
            if (feed != 0L)
            {
                parameters["feed"] = feed.ToString();
            }
            if (!string.IsNullOrEmpty(feedType))
            {
                parameters["feed_type"] = feedType;
            }
            VKRequestsDispatcher.DispatchRequestToVK <List <Photo> >("photos.get", parameters, callback, (Func <string, List <Photo> >)(jsonStr =>
            {
                try
                {
                    return(JsonConvert.DeserializeObject <GenericRoot <VKList <Photo> > >(jsonStr).response.items);
                }
                catch (Exception)
                {
                    return(new List <Photo>());
                }
            }), false, true, new CancellationToken?(), null);
        }
Пример #27
0
        private static void DoDispatch2(string baseUrl, string methodName, Dictionary <string, string> parameters)
        {
            parameters["v"] = VKConstants.API_VERSION;
            AutorizationData autorizationData1 = VKRequestsDispatcher._autorizationData;

            if (!string.IsNullOrEmpty(autorizationData1 != null ? autorizationData1.access_token : null))
            {
                parameters["access_token"] = VKRequestsDispatcher._autorizationData.access_token;
            }
            VKRequestsDispatcher.AddLangParameter(parameters);
            AutorizationData autorizationData2 = VKRequestsDispatcher._autorizationData;

            if (!string.IsNullOrEmpty(autorizationData2 != null ? autorizationData2.secret : null))
            {
                if (parameters.ContainsKey("sig"))
                {
                    parameters.Remove("sig");
                }
                string str1 = JsonWebRequest.ConvertDictionaryToQueryString(parameters, false);
                if (str1 != string.Empty)
                {
                    str1 = "?" + str1;
                }
                string str2 = VKRequestsDispatcher.HashString("/method/" + methodName + str1 + VKRequestsDispatcher._autorizationData.secret);
                parameters["sig"] = str2.ToLower();
            }
            JsonWebRequest.SendHTTPRequestAsync(!VKRequestsDispatcher.USE_HTTP ? "https://" + baseUrl : "http://" + baseUrl, parameters, (Action <JsonResponseData>)(jsonResp =>
            {
                if (jsonResp.IsSucceeded)
                {
                }
            }));
        }
Пример #28
0
 private static void DoLoadNewsFeed(string methodName, Dictionary <string, string> paramDict, Action <BackendResult <NewsFeedData, ResultCode> > callback)
 {
     VKRequestsDispatcher.DispatchRequestToVK <NewsFeedData>(methodName, paramDict, callback, (Func <string, NewsFeedData>)(jsonStr =>
     {
         List <int> resultCounts1;
         jsonStr = VKRequestsDispatcher.GetArrayCountsAndRemove(jsonStr, "photos", out resultCounts1);
         List <int> resultCounts2;
         jsonStr = VKRequestsDispatcher.GetArrayCountsAndRemove(jsonStr, "photo_tags", out resultCounts2);
         NewsFeedData response = JsonConvert.DeserializeObject <GenericRoot <NewsFeedData> >(jsonStr).response;
         NewsFeedType result1;
         if (Enum.TryParse <NewsFeedType>(response.feed_type, out result1))
         {
             response.FeedType = new NewsFeedType?(result1);
         }
         VKList <UserNotification> notifications = response.notifications;
         if ((notifications != null ? notifications.items :  null) != null)
         {
             foreach (UserNotification userNotification in response.notifications.items)
             {
                 UserNotificationType result2;
                 if (Enum.TryParse <UserNotificationType>(userNotification.type, out result2))
                 {
                     userNotification.Type = result2;
                 }
             }
         }
         return(response);
     }), false, true, new CancellationToken?(), null);
 }
Пример #29
0
        public static void DispatchLoginRequest(string login, string password, string code, bool forceSms, Action <BackendResult <AutorizationData, ResultCode> > callback, CancellationToken?cancellationToken = null)
        {
            Dictionary <string, string> dictionary1 = new Dictionary <string, string>();

            dictionary1["grant_type"]    = "password";
            dictionary1["client_id"]     = VKConstants.ApplicationID;
            dictionary1["client_secret"] = VKConstants.ApplicationSecretKey;
            dictionary1["username"]      = login;
            dictionary1["password"]      = password;
            dictionary1["2fa_supported"] = "1";
            dictionary1["device_id"]     = AppGlobalStateManager.Current.GlobalState.DeviceId;

            if (!string.IsNullOrEmpty(code))
            {
                dictionary1["code"] = code;
            }
            else if (forceSms)
            {
                dictionary1["force_sms"] = "1";
            }
            dictionary1["scope"] = "notify, friends, photos, audio, video, docs, notes, pages, status, wall, groups, messages, notifications, stats, market";
            if (VKRequestsDispatcher.USE_HTTP)
            {
                dictionary1["scope"] = dictionary1["scope"] + ", nohttps";
            }
            VKRequestsDispatcher.DoDispatch <AutorizationData>(VKRequestsDispatcher.LoginUri, "", dictionary1, callback, new Func <string, AutorizationData>(JsonConvert.DeserializeObject <AutorizationData>), false, true, cancellationToken, null);
        }
Пример #30
0
        public void UnregisterDevice(string deviceId, Action <BackendResult <VKClient.Common.Backend.DataObjects.ResponseWithId, ResultCode> > callback)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            parameters["device_id"] = deviceId;
            VKRequestsDispatcher.DispatchRequestToVK <VKClient.Common.Backend.DataObjects.ResponseWithId>("account.unregisterDevice", parameters, callback, (Func <string, VKClient.Common.Backend.DataObjects.ResponseWithId>)(jsonStr => new VKClient.Common.Backend.DataObjects.ResponseWithId()), false, true, new CancellationToken?(), null);
        }