Exemplo n.º 1
0
        private void getJsonItems(string filename)
        {
            URLLookup uRLLookupChoreo = new URLLookup(session);

            // Set inputs
            uRLLookupChoreo.setAccessToken(accessToken);
            uRLLookupChoreo.setIDs(pageURL);

            // Execute Choreo
            URLLookupResultSet uRLLookupResults = uRLLookupChoreo.execute();

            // Print results
            //Console.WriteLine(uRLLookupResults.Response);
            string s_lookup = uRLLookupResults.Response;
            JObject json_lookup = JObject.Parse(s_lookup);

            string page_id = (string)json_lookup[pageURL]["id"];
            Console.WriteLine("page ID = " + page_id);

            GetObject getObjectChoreo = new GetObject(session);

            // Set inputs
            getObjectChoreo.setAccessToken(accessToken);
            getObjectChoreo.setFields("insights");
            getObjectChoreo.setObjectID(page_id);

            // Execute Choreo
            GetObjectResultSet getObjectResults = getObjectChoreo.execute();

            string search_it = getObjectResults.Response;
            JObject j_search_it = JObject.Parse(search_it);
            System.IO.StreamWriter file = new System.IO.StreamWriter(filename);

            int i = 0;
            string name_token = (string)j_search_it["insights"]["data"][0]["name"];

            while (name_token != null)
            {
                file.WriteLine("name: " + (string)j_search_it["insights"]["data"][i]["name"]);
                file.WriteLine("title: " + (string)j_search_it["insights"]["data"][i]["title"]);
                file.WriteLine("description: " + (string)j_search_it["insights"]["data"][i]["description"]);
                file.WriteLine("");
                i++;
                try
                {
                    name_token = (string)j_search_it["insights"]["data"][i]["name"];
                }
                catch
                {
                    name_token = null;
                }

            }
            file.Close();
        }
Exemplo n.º 2
0
        // find youtube videos on Facebook to determine how many times they have been shared
        public int GetFBYTVideoShares(string video_id)
        {
            URLLookup uRLLookupChoreo = new URLLookup(session);

            // Set inputs
            uRLLookupChoreo.setAccessToken(accessToken);
            string video_url = "https://www.youtube.com/watch?v=" + video_id;
            uRLLookupChoreo.setIDs(video_url);

            // Execute Choreo
            URLLookupResultSet uRLLookupResults = uRLLookupChoreo.execute();
            JObject json_response = JObject.Parse(uRLLookupResults.Response);
            string s_shares = "";
            try
            {
                s_shares = (string)json_response[video_url]["share"]["share_count"];
            }
            catch
            {
                s_shares = "0";
            }
            return int.Parse(s_shares);
        }