예제 #1
0
        private void frndPostBtn_Click(object sender, EventArgs e)
        {
            try
            {

                //same thing pass your app token
                FacebookAPI api = new FacebookAPI(myToken.Default.token);
                //build a dictionary

                Dictionary<string, string> postArgs = new Dictionary<string, string>();
                postArgs["message"] = txtFrndPost.Text;//key message, value text

                //send to fb
                JSONObject post = api.Post("/ " + frndIDBoxMsg.Text + "/feed", postArgs);

                //clear friend wall
                //refresh data
                getSentMessage();
                //clear text box
                txtFrndPost.Text = "";
            }
            catch (FacebookAPIException exr)
            {

                Console.WriteLine(exr.Message);
            }
        }
예제 #2
0
        private void StatusUpdate_Click(object sender, EventArgs e)
        {
            try
            {

                //same thing pass your app token
                FacebookAPI api = new FacebookAPI(myToken.Default.token);
                //build a dictionary

                Dictionary<string, string> postArgs = new Dictionary<string, string>();
                postArgs["message"] = txtPost.Text;//key message, value text
                //postArgs["picture"] = "http://test.com/folder/test-image.jpg";//pass a image url

                //send to fb
                JSONObject post = api.Post("/ " + myToken.Default.userId + "/feed", postArgs);

                //clear wall
                myWall.Items.Clear();
                //refresh data
                getMyWallData();
                //clear text box
                txtPost.Text = "";
            }
            catch (FacebookAPIException exr)
            {

                Console.WriteLine(exr.Message);
            }
        }
        //private string GetPostAuthorForLikerCommenter(JSONObject oLikerCommenter)
        //{
        //    JSONObject oFirstResult = null;
        //    foreach (KeyValuePair<string, List<JSONObject>> kvp in oPosts)
        //    {
        //        oFirstResult = kvp.Value.FirstOrDefault(x => x.Dictionary["post_id"].String == oLikerCommenter.Dictionary["post_id"].String);
        //        if (oFirstResult!=null)
        //        {
        //            return oFirstResult.Dictionary["actor_id"].String;
        //        }
        //    }

        //    return null;
        //}

        private List<JSONObject> FQLBatchRequest(FacebookAPI fb, List<string> oQueries)
        {
            Dictionary<string, string> oBatchArguments = new Dictionary<string, string>();
            string oBatch;
            int nrOfQueries = oQueries.Count;
            int nrOfCalls = (int)Math.Ceiling((double)nrOfQueries / 49);
            int startIndex, endIndex;
            List<JSONObject> results = new List<JSONObject>();

            for (int i = 0; i < nrOfCalls; i++)
            {
                ReportProgress(String.Format(
                        "Step {0}/{1}: Downloading Friends of Friends data (batch {2}/{3})",
                        CurrentStep, NrOfSteps, i+1, nrOfCalls));
                startIndex = i * 49;
                endIndex = nrOfQueries - startIndex <= 49 ? nrOfQueries - startIndex : 49;
                oBatch = String.Empty;
                oBatch += "[";
                foreach (string oQuery in oQueries.Skip(startIndex).Take(endIndex))
                {

                    oBatch += "{\"method\":\"POST\",\"relative_url\":\"method/fql.query?query=" + oQuery + "\",},";

                }
                oBatch += "]";
                oBatchArguments.Clear();
                oBatchArguments.Add("batch", oBatch);
                results.Add(fb.Post("", oBatchArguments));
            }

            return results;
        }