public void getChallenge() { //update challenge and return if we are loggin or not string JsonResponse = HTTP_Request.HTTP_GET("/api/v3/login", null); requests.response response = JsonConvert.DeserializeObject <requests.response>(JsonResponse); if (response.success == "true") { challenge = response.result.challenge; System.Diagnostics.Debug.WriteLine("Challenge : " + challenge); if (response.result.logged_in == "true") { loggedIn = true; Console.WriteLine("You are now logged in"); } else if (response.result.logged_in == "false") { loggedIn = false; } else { throw new LoginFailedException("an error append in getting the loggin"); } } else { throw new LoginFailedException(); } }
public requests.configuration.lan_browser.LanHostObject getListLanHostObject() { string JsonResponse = HTTP_Request.HTTP_GET("/api/v3/lan/browser/pub", null); requests.configuration.lan_browser.LanHostObject response = JsonConvert.DeserializeObject <requests.configuration.lan_browser.LanHostObject>(JsonResponse); if (response.success == "true") { return(response); } return(null); }
public requests.configuration.lan_browser.LanInterfaces getLanInterfaces() { string JsonResponse = HTTP_Request.HTTP_GET("/api/v3/lan/browser/interfaces", null); requests.configuration.lan_browser.LanInterfaces response = JsonConvert.DeserializeObject <requests.configuration.lan_browser.LanInterfaces>(JsonResponse); if (response.success == "true") { return(response); } return(null); }
public bool getWifiInfo() { string JsonResponse = HTTP_Request.HTTP_GET("/api/v2/wifi/config/", null); requests.response response = JsonConvert.DeserializeObject <requests.response>(JsonResponse); if (response.success == "true") { if (response.result.enabled == "true") { return(true); } } return(false); }
} // device name like : "computer of henri" public bool authorizeApp() { // filling the data in order to send them requests.authorisation authorisationRequest = new requests.authorisation(); authorisationRequest.app_id = app_id; authorisationRequest.app_name = app_name; authorisationRequest.app_version = version; authorisationRequest.device_name = deviceName; //serializing string authReq = JsonConvert.SerializeObject(authorisationRequest); string authorisation = HTTP_Request.HTTP_POST("/api/v3/login/authorize", authReq); requests.response response = JsonConvert.DeserializeObject <requests.response>(authorisation); if (response.success == "true") { //printing advertissement Console.WriteLine("Accept the binding request on the screen of your freebox revolution"); app_token = response.result.app_token; track_id = response.result.track_id; //tracking pending ... bool requestEnded = false; bool printPending = false; int pendingState = 0; while (requestEnded == false) { authorisation = HTTP_Request.HTTP_GET("/api/v3/login/authorize/" + track_id, null); response = JsonConvert.DeserializeObject <requests.response>(authorisation); if (response.success == "true") { string status = response.result.status; //if we must return to the line if (status != "pending" && printPending) { Console.WriteLine(""); } //checking the status if (status == "unknow") { Console.WriteLine("Status unknow"); return(false); } else if (status == "pending") { string add = ""; if (printPending) { // determining add : switch (pendingState) { case 0: add = "|"; break; case 1: add = "/"; break; case 2: add = "-"; break; case 3: add = "\\"; break; case 4: add = "|"; break; case 5: add = "/"; break; case 6: add = "-"; break; case 7: add = "\\"; pendingState = -1; break; default: add = "|"; pendingState = -1; break; } pendingState++; Console.SetCursorPosition(Console.CursorLeft - 1, Console.CursorTop); Console.Write(add); } else { Console.Write("Pending... "); printPending = true; } } else if (status == "timeout") { Console.WriteLine("request timeout"); return(false); } else if (status == "granted") { requestEnded = true; Console.WriteLine("request ok"); return(true); } else if (status == "denied") { Console.WriteLine("request denied"); return(false); } else { Console.WriteLine("unknow request response : " + status); return(false); } } } } return(false); }