示例#1
0
        static void Main()
        {
            // These Keys come from https://apps.twitter.com/app/99999999/keys
            // The numberic value ( 999999999 ) in the URL needs to be sent to Gnip to associate with your account
            // in order to authorize you to use the Insights APIs.
            const string consumerKey = "CONSUMER_KEY";
            const string consumerSecret = "CONSUMER_SECRET";

            //  These keys come from either the same page as the above, or from the three-legged-oauth process that
            // allows another account to authorize you to retrieve engagement data on their behalf.

            string token = "TOKEN";
            string tokenSecret = "TOKEN_SECRET";

            // To access Totals for unowned accounts, make sure the token/tokenSecret are null.
            // If they are set, Totals will be "locked" to the account associated with those tokens.
            // token = null;
            // tokenSecret = null;

            // Set these flags to control which test(s) is/are executed

            var EngagementTest = true;
            var AudienceTest = true;

            if (EngagementTest)
            {
                var engagement = new EngagementAPI(consumerKey, consumerSecret, token, tokenSecret);
                TestEngagement(engagement);
            }

            if (AudienceTest)
            {
                var audience = new AudienceAPI(consumerKey, consumerSecret, token, tokenSecret);
                TestAudience(audience);
            }

            Console.WriteLine("Press <Return> to Exit.");
            Console.ReadLine();
        }
示例#2
0
        private static void TestEngagement(EngagementAPI engagement)
        {
            string[] tweetIds = new[] { "741399648594579456" };

            Console.WriteLine("28Hr");
            var response28Hr = engagement.Get28Hr(tweetIds);
            if (response28Hr.ErrorFlag) Console.WriteLine("Error:");
            Console.WriteLine(response28Hr.ResponseString);

            Console.WriteLine("Historical");
            var responseHistorical = engagement.GetHistorical(tweetIds);
            if (responseHistorical.ErrorFlag) Console.WriteLine("Error:");
            Console.WriteLine(responseHistorical.ResponseString);

            Console.WriteLine("Totals");
            var responseTotal = engagement.GetTotals(tweetIds);
            if (responseTotal.ErrorFlag) Console.WriteLine("Error:");
            Console.WriteLine(responseTotal.ResponseString);
        }