Пример #1
0
        public void put(InfoClass.GroupList GroupList, InfoClass.GroupPost GroupPost, InfoClass.account account, string message, string attachments, string post_id, string source_id)
        {
            if (message == null && attachments == null || GroupList.AttachmentsNullBlock && attachments == null || GroupList.AttachmentsNullBlock && (!attachments.Contains("photo") && !attachments.Contains("video")))
            {
                Console.WriteLine("info: Новость https://vk.com/wall{0}_{1} забракована в WallPost.cs, UserID: {2}, ID: {3}, группа: https://vk.com/public{4}", source_id, post_id, account.UserID, account.id, GroupPost.GroupID.Replace("-", ""));
                GroupList = null; message = null; attachments = null; GroupPost = null; account = null; post_id = null; source_id = null;
            }
            else
            {
                Console.WriteLine("info: {5} https://vk.com/wall{0}_{1}, UserID: {3}, ID: {4}, группа https://vk.com/public{2}", source_id, post_id, GroupPost.GroupID.Replace("-", ""), account.UserID, account.id, (GroupList.ModerationNews ? "Отправляем в модерацию новость" : "Публикуем новость"));
                string tmp = new PostAPI().post("https://api.vk.com/method/wall.post", ("owner_id=" + GroupPost.GroupID + (message != null ? "&message=" + HttpUtility.UrlEncode(message) : "") + (attachments == null ? "" : "&attachments=" + attachments) + "&from_group=1&access_token=" + (GroupList.ModerationNews ? account.ModerationToken : account.token)), source_id, post_id, account.UserID, GroupList.GroupID);
                string s = new Regex("post_id\":([0-9]+)").Match(tmp).Groups[1].Value.Trim();

                //Ставим ключевые слова для фотографии
                if (account.KeyPhoto != 0 && s != "" && account.UploadPhoto)
                    new PhotoEdit().put(GroupPost.GroupID, s, account, post_id, source_id, GroupList.ModerationNews);
                s = null; tmp = null;

                //Чистим ресурсы
                GroupList = null; message = null; attachments = null; GroupPost = null; post_id = null; source_id = null;

                //Ждем между новостями
                int sleep = new Random().Next(account.RandomStart, account.RandomNext);
                System.Threading.Thread.Sleep(1000 * sleep);
                account = null;
            }
        }
Пример #2
0
        public string get(string video_id, string owner_id, string token, string AccountID, string GroupID)
        {
            string tmp = new PostAPI().post("https://api.vk.com/method/video.add", ("owner_id=" + owner_id + "&video_id=" + video_id + "&access_token=" + token), null, null, AccountID, GroupID);
            string s = new Regex("{\"response\":([0-9]+)}").Match(tmp).Groups[1].Value;

            //Возврат результатов и очистка ресурсов
            AccountID = null; GroupID = null; video_id = null; owner_id = null; token = null; tmp = null;
            return (s != null && s.Trim() != "" ? s : s = null);
        }
Пример #3
0
        public string get(List<InfoClass.Image> ImgUrl, InfoClass.GroupPost GroupPost, InfoClass.GroupList GroupList, InfoClass.account account)
        {
            try
            {
                //Наш результат
                StringBuilder result = new StringBuilder();

                //Если картинок нету
                if (ImgUrl == null)
                {
                    ImgUrl = null; GroupPost = null; account = null; result = null;
                    return null;
                }

                //Загружаем все картинки
                foreach (InfoClass.Image s in ImgUrl)
                {
                    //Загружаем картинку и получаем данные с хешем
                    string photo = HttpUploadPhoto(s.src_big, (GroupList.ModerationNews ? GroupPost.ModerationUploadURL : GroupPost.UploadURL));
                    if (photo == null)
                        continue; //Если была ошибка во время загрузки картинки, то переходим на следующею картинку

                    //Работа с данными
                    GroupCollection g = new Regex("\"server\":([0-9]+),\"photo\":\"(.*)\",\"hash\":\"([a-zA-Z0-9]+)\"").Match(photo.Replace("\\", "").Replace(" ", "")).Groups;
                    string tmp = new PostAPI().post("https://api.vk.com/method/photos.saveWallPhoto", ("group_id=" + GroupPost.GroupID.Replace("-", "").Trim() + "&server=" + g[1].Value + "&photo=" + HttpUtility.UrlEncode(g[2].Value) + new Regex("(&gid=[0-9]+)&").Match(GroupList.ModerationNews ? GroupPost.ModerationUploadURL : GroupPost.UploadURL).Groups[1].Value + "&hash=" + g[3].Value + "&access_token=" + (GroupList.ModerationNews ? account.ModerationToken : account.token)), null, null, account.UserID, GroupList.GroupID);
                    string res = new Regex("id\":\"([a-zA-Z-_0-9]+)").Match(tmp).Groups[1].Value + ",";

                    //Добовляем результат
                    if (res.Replace(",", "").Replace(" ", "").Trim() != "")
                        result.Append(new Regex("id\":\"([a-zA-Z-_0-9]+)").Match(tmp).Groups[1].Value + ",");

                    //Чистим ресурсы
                    photo = null; g = null; tmp = null; res = null;
                }

                //Возвращаем результат всех фотографий
                ImgUrl = null; GroupPost = null; GroupList = null; account = null;
                return result.ToString().Replace(",", "").Replace(" ", "").Trim() == "" ? null : result.ToString();
            }
            catch (Exception e)
            {
                Console.WriteLine("error: Ошибка во время сохранения фотографий на сервере загрузки, UserID: {0}, ID: {1}, группа: {2}", account.UserID, account.id, GroupList.GroupID);
                if (e != null)
                    Console.WriteLine("Код ошибки: {1}{0}{1}{1}", e, Environment.NewLine);

                return null;
            }
        }
Пример #4
0
        public string get(string token, string gPost)
        {
            int CountRefresh = 0;
            Refresh: string tmp = new PostAPI().post("https://api.vkontakte.ru/method/photos.getWallUploadServer", ("group_id=" + gPost.Replace("-", "").Trim() + "&access_token=" + token), null, null, null, null).Replace("\\/", "/").Trim();
            string url = new Regex("\"upload_url\":\"([^\"]+)\"").Match(tmp).Groups[1].Value;

            //Проверка на капчу и получение URL
            if ((new Regex("userauthorizationfailed:invalidaccess_token").Match(tmp.ToLower().Replace(" ", ""))).Success || CountRefresh == 3)
            {
                Console.WriteLine("Error UploadURL.cs: {0}\nToken: {1}\nНажмите любую клавишу для завершения программы.", new Regex("\"error_msg\":\"([^\"]+)\"").Match(tmp).Groups[1].Value, token);
                Console.ReadKey();
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
            else if ((url == null || url.Trim() == "") && CountRefresh != 3)
            {
                url = null; tmp = null; CountRefresh++; goto Refresh;
            }

            //Чистим ресурсы
            tmp = null; token = null; gPost = null;
            return url;
        }
Пример #5
0
        public string get(string token)
        {
            int CountRefresh = 0;
            Refresh: string tmp = new PostAPI().post("https://api.vk.com/method/users.get", ("&access_token=" + token), null, null, null, null).Replace("\\/", "/").Replace(" ", "").ToLower().Trim();
            string id = new Regex("\"uid\":([0-9]+),?\"").Match(tmp).Groups[1].Value;

            //Проверка на капчу и получение URL
            if ((new Regex("userauthorizationfailed:invalidaccess_token").Match(tmp)).Success || CountRefresh == 3)
            {
                Console.WriteLine("Error UserGet.cs: {0}\nToken: {1}\nНажмите любую клавишу для завершения программы.", new Regex("\"error_msg\":\"([^\"]+)\"").Match(tmp).Groups[1].Value, token);
                Console.ReadKey();
                System.Diagnostics.Process.GetCurrentProcess().Kill();
            }
            else if ((id == null || id.Trim() == "") && CountRefresh != 3)
            {
                id = null; tmp = null; CountRefresh++; goto Refresh;
            }

            //Чистим ресурсы
            tmp = null; token = null;
            return id.Trim();
        }