private void sendphotoForm_Load(object sender, EventArgs e)
        {
            textBox1.Text = Properties.Settings.Default.textid;
            WebClient client = new WebClient();



            string request2 = "https://api.vk.com/method/groups.get?user_id=" + Form1.idd + "&fields=name,photo_100&extended=1&access_token=" + access_token + "&v=5.87";
            string answer   = Encoding.UTF8.GetString(client.DownloadData(request2));

            pictureBox1.Visible = false;
            listView1.Clear();



            //ListViewItem lvi = new ListViewItem("test1");
            //listView1.Items.Add(lvi);
            allusergroups = JsonConvert.DeserializeObject <groups>(answer);

            int valuegroups = 0;



            for (int itemIndex = 0; itemIndex < allusergroups.response.items.Length; itemIndex = itemIndex + 1)
            {
                try
                {
                    string[] names = new string[3];



                    valuegroups = valuegroups + 1;

                    names[0] = allusergroups.response.items[itemIndex].name;
                    names[1] = allusergroups.response.items[itemIndex].id.ToString();
                    names[2] = allusergroups.response.items[itemIndex].photo_100;
                    pictureBox1.Load(allusergroups.response.items[itemIndex].photo_100);
                    Application.DoEvents();
                    imageList1.Images.Add(pictureBox1.Image);
                    parentForm.progressBar1.Maximum = allusergroups.response.items.Length;
                    parentForm.progressBar1.Value   = valuegroups;



                    ListViewItem lvi = new ListViewItem(names, imageList1.Images.Count - 1);
                    listView1.Items.Add(lvi);

                    if (parentForm.progressBar1.Value == parentForm.progressBar1.Maximum)
                    {
                        parentForm.progressBar1.Visible = false;
                        parentForm.label1.Visible       = false;
                    }
                }
                catch (Exception)
                {
                    label2.Text = "Возникла ошибка !";
                }
            }
        }
Exemplo n.º 2
0
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url.ToString().Contains("access_token="))
            {
                webBrowser1.Visible = false;
                access_token        = e.Url.ToString();
                int pos = access_token.IndexOf("access_token=");
                pos         += "access_token=".Length;
                access_token = access_token.Remove(0, pos);
                pos          = access_token.IndexOf("&");
                access_token = access_token.Remove(pos);

                if (e.Url.ToString().Contains("user_id="))
                {
                    idd = e.Url.ToString();
                    int poss = idd.IndexOf("user_id=");
                    poss += "user_id=".Length;
                    idd   = idd.Remove(0, poss);
                    poss  = idd.IndexOf("&");
                    idd   = idd.Remove(poss);
                    try
                    {
                        string request = "https://api.vk.com/method/users.get?user_ids=" + idd + "&fields=photo_100,bdate&access_token=" + access_token + "&v=5.92";
                        //string request2 = "https://api.vk.com/method/groups.get?user_id=56929156&fields=photo_100&extended=1&access_token=" + access_token + "&v=5.87";
                        WebClient client = new WebClient();
                        //string answer = client.DownloadString(request);

                        string answer = Encoding.UTF8.GetString(client.DownloadData(request));



                        User user = JsonConvert.DeserializeObject <User>(answer);

                        string allgroups = "https://api.vk.com/method/groups.get?user_id=" + idd + "&fields=name&extended=1&access_token=" + access_token + "&v=5.92";

                        string answerallgroups = Encoding.UTF8.GetString(client.DownloadData(allgroups));
                        groups allusergroups   = JsonConvert.DeserializeObject <groups>(answerallgroups);



                        webBrowser1.Visible = false;

                        AvatarPictureBox.Load(user.response[0].photo_100);
                        FirstNameLabel.Text  = user.response[0].first_name;
                        SecondNameLabel.Text = user.response[0].last_name;

                        userIdd = user.response[0].id.ToString();
                    }
                    catch (Exception)
                    {
                        EvilLabel.Text = "Возникла ошибка !";
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            if (e.Url.ToString().Contains("access_token="))
            {
                webBrowser1.Visible = false;
                access_token        = e.Url.ToString();
                int pos = access_token.IndexOf("access_token=");
                pos         += "access_token=".Length;
                access_token = access_token.Remove(0, pos);
                pos          = access_token.IndexOf("&");
                access_token = access_token.Remove(pos);

                if (e.Url.ToString().Contains("user_id="))
                {
                    userId = e.Url.ToString();
                    int poss = userId.IndexOf("user_id=");
                    poss  += "user_id=".Length;
                    userId = userId.Remove(0, poss);
                    poss   = userId.IndexOf("&");
                    userId = userId.Remove(poss);
                    try
                    {
                        string    request = "https://api.vk.com/method/users.get?user_ids=" + userId + "&fields=photo_100,bdate&access_token=" + access_token + "&v=5.92";
                        WebClient client  = new WebClient();

                        string answer = Encoding.UTF8.GetString(client.DownloadData(request));



                        User   user            = JsonConvert.DeserializeObject <User>(answer);
                        string allgroups       = "https://api.vk.com/method/groups.get?user_id=" + userId + "&fields=name&extended=1&access_token=" + access_token + "&v=5.92";
                        string answerallgroups = Encoding.UTF8.GetString(client.DownloadData(allgroups));
                        groups allusergroups   = JsonConvert.DeserializeObject <groups>(answerallgroups);

                        string     request2 = "https://api.vk.com/method/groups.getById?group_id=177471057&fields=is_member&access_token=" + access_token + "&v=5.92";
                        string     answer2  = Encoding.UTF8.GetString(client.DownloadData(request2));
                        CheckGroup cg       = new CheckGroup();
                        cg = JsonConvert.DeserializeObject <CheckGroup>(answer2);

                        if (cg.response[0].is_member == 1)
                        {
                            autoAnswerButton.Enabled = true;
                            Pusia.Enabled            = true;
                            sendphoto.Enabled        = true;
                            AButto.Enabled           = true;
                            delete_friends.Enabled   = true;
                            Likebutton.Enabled       = true;
                        }
                        else
                        {
                            MessageBox.Show("Вы не вступили в приватную группу. Напишите в лс оффициальной группы, чтобы вас добавили.", "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            Application.Exit();
                        }

                        webBrowser1.Visible = false;

                        AvatarPictureBox.Load(user.response[0].photo_100);
                        FirstNameLabel.Text  = user.response[0].first_name;
                        SecondNameLabel.Text = user.response[0].last_name;
                    }
                    catch (Exception)
                    {
                        EvilLabel.Text    = "Возникла ошибка !";
                        EvilLabel.Visible = true;
                    }
                }
            }
        }