Ejemplo n.º 1
0
 public v2_Videos(APIRequestHandler aReq, oAuthAuth oaCreds,
                  Serializer ser)
 {
     this.aReq = aReq; this.oaCreds = oaCreds;
     this.ser  = ser;
 }
Ejemplo n.º 2
0
 public v2_CodingCategories(APIRequestHandler aReq, oAuthAuth oaCreds,
                            Serializer ser)
 {
     this.aReq = aReq; this.oaCreds = oaCreds;
     this.ser  = ser;
 }
Ejemplo n.º 3
0
 public v2_ScheduledBroadcast(APIRequestHandler aReq, oAuthAuth oaCreds,
                              Serializer ser)
 {
     this.aReq = aReq; this.oaCreds = oaCreds;
     this.ser  = ser;
 }
Ejemplo n.º 4
0
        static void ConsoleOnlyTest() {
            string testUser = "******";

            Console.WriteLine("Creating Object!");

            var serverAPIURL = "http://callumcarmicheal.com/LCAPI/"; // LINK TO WHERE YOU UPLOADED AND SETUP THE PHP SCRIPT
            Request apiRequest = new Request(new ServResources(serverAPIURL));

            Console.WriteLine("Requesting a GUID!");
            var guidReqResponse = apiRequest.getNewGUID();

            // Print our information from the guidReqResponse
            Console.WriteLine("Recieved Object Back!");
            Console.WriteLine("Guid:   " + guidReqResponse.GUID);
            Console.WriteLine("Url:    " + guidReqResponse.URL);
            Console.WriteLine("Err:    " + guidReqResponse.Error);
            Console.WriteLine("ErrMSG: " + guidReqResponse.Error_Message);

            Console.WriteLine("");

            Console.WriteLine("Requesting a Authorization GUID and URL");
            var apiSetupResponse = apiRequest.SetupAPIRequest(false); // When using our own checking method, we just check to see if its "RETURN"

            if (apiSetupResponse.getState() != ResponseState.RETURN) {
                Console.WriteLine("Unexpected Response (" + apiSetupResponse.getState().ToString() + "): " + apiSetupResponse.getMessage());
                Console.ReadKey(); return;
            }

            // Get our token state
            GUID_Status guidStatus;
            Console.WriteLine("Calling API To Check Token!");

            int i = 0;
            while (true) {
                // Now we play the waiting game!
                //Console.WriteLine("State: " + state.ToString() + "\n");

                // Check our GUID State
                guidStatus = apiRequest.getGUIDState();

                if (guidStatus == GUID_Status.STATE_ID_VALID) {
                    ConColF(ConsoleColor.Green);
                    Console.WriteLine("Token recieved.");
                    ConColF(ConsoleColor.Black);
                    break;
                }

                // Wait 0.5 seconds before checking
                // for a token!
                System.Threading.Thread.Sleep(500);

                i++;

                if (i <= 5) {
                    i = 0;

                    ConColF(ConsoleColor.Yellow);
                    Console.WriteLine("Still waiting for token.");
                    ConColF(ConsoleColor.Black);
                }
            }

            ConColF(ConsoleColor.Cyan);
            Console.Write("Requesting Token: ");

            ConColF(ConsoleColor.Green);

            var apiAccess = new APIAccess(apiRequest);
            var apiToken = apiAccess.getBearerCode();

            if (apiToken.Error) {
                ConColF(ConsoleColor.Red);
                Console.WriteLine("Failed.");

                Console.WriteLine("EMsg: " + apiToken.Error_Message);
                Console.ReadKey(); return;
            }

            Console.WriteLine("Success.");
            ConColF(ConsoleColor.White);

            Console.WriteLine("Bearer Code: " + apiToken.Token);

            // Call the API
            Console.Write("Test Calling the API: ");

            oAuthAuth oaCreds = new oAuthAuth(apiToken.Token);
            var aReq = new APIRequestHandler();
            var jsonString = aReq.getAPIJson(APIResources.getUser(testUser), oaCreds, true);
            
            Console.WriteLine("JSON STRING: ");
                Console.WriteLine(jsonString + "\n\n");

            Console.Write("Attempting to serialize json: "); {
                var eng = new Engine(oaCreds);
                var ser = new LiveCodingTV.API.Wrappers.Serializer();

                User user = new User();
                
                try {
                    // Surround with a try and catch!
                    user = eng.User.getUser(testUser);
                } catch(Exception ex) {
                    ConColF(ConsoleColor.Red);
                    Console.WriteLine("Error.");
                    Console.WriteLine("EMsg: " + ex.Message);
                    Console.ReadKey(); return;
                }

                // Set the console color and print Success
                ConColF(ConsoleColor.Green);
                    Console.WriteLine("Success");
                ConColF(ConsoleColor.DarkMagenta);

                Console.WriteLine("============================\tUser Information");

                // Print some information about the user
                ConPrintCol("Username",     user.Username);
                ConPrintCol("Country",      user.Country);
                ConPrintCol("Fav Line",     user.FavoriteLineOfCode);
            } 

            Console.ReadKey();
        }
Ejemplo n.º 5
0
 public v2_CodingCategories(APIRequestHandler aReq, oAuthAuth oaCreds, 
     Serializer ser) {
     this.aReq = aReq; this.oaCreds = oaCreds;
     this.ser  = ser;
 }
Ejemplo n.º 6
0
 public v2_Videos(APIRequestHandler aReq, oAuthAuth oaCreds,
     Serializer ser) {
     this.aReq = aReq; this.oaCreds = oaCreds;
     this.ser = ser;
 }
Ejemplo n.º 7
0
 public v2_ScheduledBroadcast(APIRequestHandler aReq, oAuthAuth oaCreds,
     Serializer ser) {
     this.aReq = aReq; this.oaCreds = oaCreds;
     this.ser = ser;
 }