コード例 #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();
        }