Esempio n. 1
0
        private async void button1_Click_1(object sender, EventArgs e)
        {
            //Set the post arguments for more info check the facebook graph documentation https://developers.facebook.com/docs/
            Dictionary <string, object> args = new Dictionary <string, object>();

            args["message"] = tbMessage.Text;
            args["link"]    = tbLink.Text;
            //If the user chosed to post on his wall so we'll set the privacy value to the value chosen from the Privacy ComboBox
            switch (cbPrivacy.SelectedIndex)
            {
            case 0:
                args["privacy"] = new { value = "EVERYONE" };
                break;

            case 1:
                args["privacy"] = new { value = "ALL_FRIENDS" };
                break;

            case 2:
                args["privacy"] = new { value = "SELF" };
                break;
            }
            //Post to user's wall if he chosed that
            if (cbWall.Checked)
            {
                toolStripStatusLabel1.Text = "Posting To Your Wall";
                var id = await fb.PostTaskAsync("/me/feed", args);
            }
            //Remove the privacy Key becasue posting to Groups and Pages doesn't require this Key
            args.Remove("privacy");
            //Posting to the user selected Groups
            for (int i = 0; i < GroupCb.Items.Count; i++)
            {
                if (GroupCb.GetItemChecked(i))
                {
                    toolStripStatusLabel1.Text = "Posting To Group " + Groups[i].Groupname;
                    await fb.PostTaskAsync("/" + Groups[i].GroupID + "/feed", args);
                }
            }
            //Posting to the user selected Pages
            for (int i = 0; i < PageCb.Items.Count; i++)
            {
                if (PageCb.GetItemChecked(i))
                {
                    args["access_token"]       = Pages[i].Pageaccess;
                    toolStripStatusLabel1.Text = "Posting To Page " + Pages[i].Pagename;
                    await fb.PostTaskAsync("/" + Pages[i].PageID + "/feed", args);
                }
            }
            toolStripStatusLabel1.Text = "Ready";
        }
Esempio n. 2
0
 private async void button2_Click(object sender, EventArgs e)
 {
     for (int i = 0; i < Groups.Count; i++)
     {
         if (GroupCb.GetItemChecked(i))
         {
             //Get the user posts from the selected group
             var desired_posts = Posts.Where((p) => p.FkGroup == Groups[i].GroupID).ToList();
             //Delete the user posts
             for (int j = 0; j < desired_posts.Count(); j++)
             {
                 toolStripStatusLabel1.Text = "Deleting Post From Group: " + Groups[i].Groupname;
                 await fb.DeleteTaskAsync(desired_posts[i].PostID);
             }
         }
     }
     toolStripStatusLabel1.Text = "Ready";
 }
Esempio n. 3
0
        private async void button1_Click(object sender, EventArgs e)
        {
            GroupCb.Items.Clear();
            label2.Hide();
            GroupCb.Hide();
            button2.Hide();
            button3.Show();                                       //Show the Stop Button
            dynamic groups = await fb.GetTaskAsync("/me/groups"); //Get All the user groups

            dynamic me = await fb.GetTaskAsync("/me");            //Get the user info

            for (int i = 0; i < (int)groups.data.Count; i++)
            {
                //Check if the user pressed stop button because if he did that we won't complete the search operation
                if (isCanceled)
                {
                    toolStripStatusLabel1.Text = "Canceled";
                    isCanceled = false;
                    break;
                }
                try
                {
                    //Create the query which will write into Facebook FQL to get the user's post in the selected group
                    string  query      = String.Format("SELECT message,post_id FROM stream WHERE source_id={0} and actor_id={1} and strpos(message,'{2}') >=0", groups.data[i].id, me.id, txtSpam.Text);
                    dynamic Parameters = new ExpandoObject();
                    Parameters.q = query;
                    dynamic allposts = await fb.GetTaskAsync("/fql", Parameters); //Get the user posts from the group



                    toolStripStatusLabel1.Text = "Searching in Group: " + groups.data[i].name;
                    //Check if the user has posts on this group
                    if (allposts.data.Count > 0)
                    {
                        label2.Show();
                        GroupCb.Show();                                                                                     //Show the CheckBox List for the Groups
                        txtSpam.RightToLeft = HasArabicGlyphs(allposts.data[0].message) ? RightToLeft.Yes : RightToLeft.No; //Check if the text is Arabic because if it's arabic we'll set the Right To Left Property Enabled
                        txtSpam.Text        = allposts.data[0].message;
                        //Add the group which has the user posts to the Groups List
                        Groups.Add(new Group
                        {
                            GroupID   = groups.data[i].id,
                            Groupname = groups.data[i].name
                        });
                        //Add the group the CheckBox List
                        GroupCb.Items.Add(groups.data[i].name, true);
                        for (int j = 0; j < (int)allposts.data.Count; j++)
                        {
                            //Add Post Info to the Posts List
                            Posts.Add(new Post
                            {
                                FkGroup  = groups.data[i].id,
                                PostID   = allposts.data[j].post_id,
                                PostName = allposts.data[j].message
                            });
                        }
                    }
                }
                catch {
                    toolStripStatusLabel1.Text = "Canceled";
                }
            }
            if (GroupCb.Items.Count > 0)
            {
                button2.Show();
            }
            button3.Hide();
            toolStripStatusLabel1.Text = "Ready";
        }