/// <summary>
    /// Retrieve the URL that the client should redirect the user to to perform the OAuth authorization
    /// </summary>
    /// <param name="provider"></param>
    /// <returns></returns>
    protected override string GetAuthorizationUrl(String callbackUrl)
    {
        OAuthBase auth = new OAuthBase();
        String requestUrl = provider.Host + provider.RequestTokenUrl;
        Uri url = new Uri(requestUrl);
        String requestParams = "";
        String signature = auth.GenerateSignature(url, provider.ClientId, provider.Secret, null, null, provider.RequestTokenMethod ?? "POST",
            auth.GenerateTimeStamp(), auth.GenerateTimeStamp() + auth.GenerateNonce(), out requestUrl, out requestParams,
            new OAuthBase.QueryParameter(OAuthBase.OAuthCallbackKey, auth.UrlEncode(callbackUrl)));
        requestParams += "&oauth_signature=" + HttpUtility.UrlEncode(signature);
        WebClient webClient = new WebClient();
        byte[] response;
        if (provider.RequestTokenMethod == "POST" || provider.RequestTokenMethod == null)
        {
            response = webClient.UploadData(url, Encoding.ASCII.GetBytes(requestParams));
        }
        else
        {
            response = webClient.DownloadData(url + "?" + requestParams);
        }
        Match m = Regex.Match(Encoding.ASCII.GetString(response), "oauth_token=(.*?)&oauth_token_secret=(.*?)&oauth_callback_confirmed=true");
        String requestToken = m.Groups[1].Value;
        String requestTokenSecret = m.Groups[2].Value;
        // we need a way to save the request token & secret, so that we can use it to get the access token later (when they enter the pin)
        // just stick it in the session for now
        HttpContext.Current.Session[OAUTH1_REQUEST_TOKEN_SESSIONKEY] = requestToken;
        HttpContext.Current.Session[OAUTH1_REQUEST_TOKEN_SECRET_SESSIONKEY] = requestTokenSecret;

        return provider.Host + provider.UserApprovalUrl + "?oauth_token=" + HttpUtility.UrlEncode(requestToken);
    }
Example #2
0
    /// <summary>
    /// WebClient.UploadFile()
    /// </summary>
    public static void UpFile()
    {
        WebClient client = new WebClient();
        client.UploadFile("http://www.baidu.com", "C:/Users/yk199/Desktop/GodWay1/Web/Log/newfile.txt");

        byte[] image = new byte[2];
        client.UploadData("http://www.baidu.com",image);
    }
Example #3
0
        public  string Push(string user_id, string title, string description, string msg_keys)
        {
            DateTime utcNow = DateTime.UtcNow;
            DateTime epoch = new DateTime(1970, 1, 1, 0, 0, 0);
            uint timestamp = (uint)(utcNow - epoch).TotalSeconds;
            uint expires = (uint)(utcNow.AddDays(1) - epoch).TotalSeconds; //一天后过期

            Dictionary<string, string> dic = new Dictionary<string, string>();
            dic.Add("method", method);
            dic.Add("apikey", apikey);
            dic.Add("timestamp", timestamp.ToString());
            dic.Add("push_type", "1"); //单播
            dic.Add("device_type", "3"); //Andriod设备 
            dic.Add("user_id", user_id);
            dic.Add("message_type", "0"); //消息
            dic.Add("messages", description);
            dic.Add("msg_keys", msg_keys); //消息标识 相同消息标识的消息会自动覆盖。只支持android。
            dic.Add("sign", StructSign("POST", url, dic, secret_key));

            StringBuilder sb = new StringBuilder();
            foreach (var d in dic)
            {
                sb.Append(d.Key + "=" + d.Value + "&");
            }
            sb.Remove(sb.Length - 1, 1);
            byte[] data = Encoding.UTF8.GetBytes(sb.ToString());

            WebClient webClient = new WebClient();
            try
            {
                webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");//采取POST方式必须加的header,如果改为GET方式的话就去掉这句话即可  
                byte[] response = webClient.UploadData(url, "POST", data);
                return Encoding.UTF8.GetString(response);
            }
            catch (WebException ex)
            {
                Stream stream = ex.Response.GetResponseStream();
                byte[] bs = new byte[256];
                int i = 0;
                int b;
                while ((b = stream.ReadByte()) > 0)
                {
                    bs[i++] = (byte)b;
                }
                stream.Close();
                return Encoding.UTF8.GetString(bs, 0, i);
            }


        
        }
 private void GetAccessToken(string requestToken, string requestTokenSecret, string verifier, out string accessToken, out string accessTokenSecret, out string username)
 {
     Uri url = new Uri(provider.Host + provider.AccessTokenUrl);
     OAuthBase auth = new OAuthBase();
     String requestUrl, requestParams;
     String signature = auth.GenerateSignature(url, provider.ClientId, provider.Secret, requestToken, requestTokenSecret, provider.RequestTokenMethod ?? "POST",
         auth.GenerateTimeStamp(), auth.GenerateTimeStamp() + auth.GenerateNonce(), out requestUrl, out requestParams,
         new OAuthBase.QueryParameter("oauth_verifier", auth.UrlEncode(verifier)));
     WebClient webClient = new WebClient();
     byte[] response = webClient.UploadData(url, Encoding.ASCII.GetBytes(requestParams + "&oauth_signature=" + HttpUtility.UrlEncode(signature)));
     String[] tokenParts = Encoding.ASCII.GetString(response).Split('&');
     if (tokenParts.Length < 2)
     {
         throw new Exception("Unexpected response to access token request: " + Encoding.ASCII.GetString(response));
     }
     accessToken = null;
     accessTokenSecret = null;
     username = null;
     foreach (String tokenPart in tokenParts)
     {
         String[] pieces = tokenPart.Split('=');
         if (pieces.Length != 2)
         {
             throw new Exception("Unable to parse HTTP response: " + tokenPart); // should not happen
         }
         switch (pieces[0])
         {
             case OAuthBase.OAuthTokenKey:
                 accessToken = pieces[1];
                 break;
             case OAuthBase.OAuthTokenSecretKey:
                 accessTokenSecret = pieces[1];
                 break;
             case "screen_name": case "user_name":
                 // Twitter provides the user name back with this call, though it's not part of the standard.
                 // we'll capture it if it's provided and leave it null if not (it's not really required for anything anyway)
                 username = pieces[1];
                 break;
             default:
                 // ignore other values
                 break;
         }
     }
 }
    //---------------------------------------------------------
    private string GetWebClientData(string targetUrl)
    {
        //Cmn.Log.WriteToFile("targetUrl", targetUrl);
        string _retVal = "";
        WebClient _webClient = new WebClient();

        //增加SessionID,为了解决当前用户登录问题
           // Cmn.Session.SetUserID("kdkkk"); //随便设置一个session 否则SessionID会变
        Cmn.Session.Set("cmn_ItfProxy_tmp","test");

        targetUrl = Cmn.Func.AddParamToUrl(targetUrl, "CurSessionID=" + Session.SessionID);

        Cmn.Log.WriteToFile("targetUrl", targetUrl);

        if (Request.Form.Count > 0) { //post方式
            string _postString = "";

            for (int _i = 0; _i < Request.Form.Count; _i++) {
                if (_postString != "") { _postString += "&"; }

                _postString += Request.Form.Keys[_i] + "=" + System.Web.HttpUtility.UrlEncode(Request.Form[_i].ToString(), Encoding.UTF8);
            }

            byte[] _postData = Encoding.GetEncoding("utf-8").GetBytes(_postString);
            _webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

            byte[] _responseData = _webClient.UploadData(targetUrl, "POST", _postData);//得到返回字符流
            _retVal = Encoding.GetEncoding("utf-8").GetString(_responseData);//解码
        }
        else {
            Stream _stream = _webClient.OpenRead(targetUrl);

            StreamReader _rd = new StreamReader(_stream, Encoding.GetEncoding("utf-8"));
            _retVal = _rd.ReadToEnd();

            _stream.Close();

        }

        return _retVal;
    }
Example #6
0
        public static void UploadData_InvalidArguments_ThrowExceptions()
        {
            var wc = new WebClient();

            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadData((string)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadData((string)null, null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadData((Uri)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadData((Uri)null, null, null); });

            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadDataAsync((Uri)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadDataAsync((Uri)null, null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadDataAsync((Uri)null, null, null, null); });

            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadDataTaskAsync((string)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadDataTaskAsync((string)null, null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadDataTaskAsync((Uri)null, null); });
            Assert.Throws<ArgumentNullException>("address", () => { wc.UploadDataTaskAsync((Uri)null, null, null); });

            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadData("http://localhost", null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadData("http://localhost", null, null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadData(new Uri("http://localhost"), null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadData(new Uri("http://localhost"), null, null); });

            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadDataAsync(new Uri("http://localhost"), null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadDataAsync(new Uri("http://localhost"), null, null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadDataAsync(new Uri("http://localhost"), null, null, null); });

            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadDataTaskAsync("http://localhost", null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadDataTaskAsync("http://localhost", null, null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadDataTaskAsync(new Uri("http://localhost"), null); });
            Assert.Throws<ArgumentNullException>("data", () => { wc.UploadDataTaskAsync(new Uri("http://localhost"), null, null); });
        }
Example #7
0
 protected override Task<byte[]> UploadDataAsync(WebClient wc, string address, byte[] data) => Task.Run(() => wc.UploadData(address, data));
Example #8
0
 public static async Task ConcurrentOperations_Throw()
 {
     await LoopbackServer.CreateServerAsync((server, url) =>
     {
         var wc = new WebClient();
         Task ignored = wc.DownloadDataTaskAsync(url); // won't complete
         Assert.Throws<NotSupportedException>(() => { wc.DownloadData(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadDataAsync(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadDataTaskAsync(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadString(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadStringAsync(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadStringTaskAsync(url); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadFile(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadFileAsync(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.DownloadFileTaskAsync(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadData(url, new byte[42]); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadDataAsync(url, new byte[42]); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadDataTaskAsync(url, new byte[42]); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadString(url, "42"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadStringAsync(url, "42"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadStringTaskAsync(url, "42"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadFile(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadFileAsync(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadFileTaskAsync(url, "path"); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadValues(url, new NameValueCollection()); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadValuesAsync(url, new NameValueCollection()); });
         Assert.Throws<NotSupportedException>(() => { wc.UploadValuesTaskAsync(url, new NameValueCollection()); });
         return Task.CompletedTask;
     });
 }
Example #9
0
    IEnumerator createAndSendFileOnFtp(string id)
    {
        ExtraEvent.firePleaseWait(true);
        t = Time.time;
        debugString = "-started:"+t;
        yield return new WaitForSeconds(1);
        byte[] img = m_sendPic.EncodeToPNG();
        string fileName = Path.GetRandomFileName();
        fileName = fileName.Replace(".","");
        //		Debug.Log("Unique fName>" + fileName+"<");

        //		ALTERNATE VERSION VV DOESN'T WORK MOUAHAHAH ^^
        //		FileStream fs =  File.Open(Application.persistentDataPath+"/test.png",FileMode.Open);
        //		fs.Flush();
        //		fs.Write(img,0,img.Length);
        //		fs.Close();
        //
        //		string filename = "Bitcherland.png";
        //		FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create("ftp://www.oneshot3d.com/ExtraTest/"+filename);
        //		ftpRequest.Method = WebRequestMethods.Ftp.UploadFileWithUniqueName;
        //		ftpRequest.Credentials = new NetworkCredential("sys_pointcub","gx8FztlI7kpM");
        //
        ////		StreamReader sr = new StreamReader(Application.persistentDataPath+"/test.png");
        ////		byte[] fileContent = Encoding.UTF8.GetBytes(sr.ReadToEnd());
        ////		sr.Close();
        ////
        ////		ftpRequest.ContentLength = fileContent.Length;
        //
        //		Stream requestStream = ftpRequest.GetRequestStream();
        //		requestStream.Write(img,0,img.Length);
        //		requestStream.Close();
        //
        //		FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
        //
        ////      Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
        //    	Debug.Log("UploadFile complete, >"+response.StatusDescription);
        //        response.Close();

        debugString += "-startwc:"+Time.time;
        WebClient wc = new WebClient();

        wc.Credentials = new NetworkCredential("sys_pointcub","gx8FztlI7kpM"); //local

        wc.UploadData("ftp://www.pointcube.com/extrabat/img/"+fileName+".png",img);
        wc.Dispose();

        debugString += "-endwc:"+Time.time;
        Debug.Log("COROUTINE UPLOAD FINNISHED");
        yield return new WaitForSeconds(1);

        StartCoroutine(fileOnServer(id,fileName));
        yield return null;
    }
    /// <summary>
    /// Retrieve access or refresh token
    /// </summary>
    /// <param name="accessCode"></param>
    /// <param name="url"></param>
    /// <param name="urlData"></param>
    /// <param name="callbackUrl">Original callback URL (used for verification by some provider)</param>
    /// <returns></returns>
    private TokenResponse GetAccessToken(string accessCode, String url, String urlData, String callbackUrl)
    {
        urlData = urlData.Replace("{REDIRECT_URI}", HttpUtility.UrlEncode(callbackUrl));
        urlData = urlData.Replace("{TOKEN}", HttpUtility.UrlEncode(accessCode));
        urlData = urlData.Replace("{CLIENTID}", provider.ClientId);
        urlData = urlData.Replace("{CLIENTSECRET}", provider.Secret);
        // I don't think we need that one - if the provider requires refresh token, we'll be using the refresh URL instead
        //if (provider.RequiresRefreshToken.GetValueOrDefault())
        //    urlData += "&access_type=offline";
        try
        {
            var client = new WebClient();
            client.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
            // TODO: support for "GET" method
            byte[] response = client.UploadData(url, Encoding.ASCII.GetBytes(urlData));
            TokenResponse tResponse = JsonConvert.DeserializeObject<TokenResponse>(Encoding.ASCII.GetString(response));

            if (tResponse.error != null)
                throw new Exception(tResponse.error);
            return tResponse;
        }
        catch (Exception ex)
        {
            if (ex is WebException)
            {
                using (var sr = new StreamReader(((WebException)ex).Response.GetResponseStream()))
                {
                    String responseString = sr.ReadToEnd();
                    if (!String.IsNullOrEmpty(responseString))
                    {
                        _log.Warn("Error Response from OAuth provider: " + responseString);
                    }
                }
            }
            throw new ValidationException(String.Format("Unable to retrieve authorization token: {0}", ex.Message));
        }
    }
Example #11
0
    public static string SendMessage(string Url, string strMessage)
    {
        string strResponse;
             // 初始化WebClient
             WebClient webClient = new WebClient();
             webClient.Headers.Add("Accept", "*/*");
             webClient.Headers.Add("Accept-Language", "zh-cn");
             webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");

             try
             {
                 byte[] responseData = webClient.UploadData(Url, "POST", Encoding.GetEncoding("UTF-8").GetBytes(strMessage));
                 string srcString = Encoding.GetEncoding("UTF-8").GetString(responseData);
                 strResponse = srcString;
             }
             catch
             {
                 return "-1";
             }
             return strResponse;
    }
Example #12
0
 static void PushImage(string file)
 {
     Console.WriteLine (file);
     using (WebClient wc = new WebClient ()) {
         wc.Headers.Add ("X-Apple-AssetKey", "F92F9B91-954E-4D63-BB9A-EEC771ADE6E8");
         wc.Headers.Add ("User-Agent", "AirPlay/160.4 (Photos)");
         wc.Headers.Add ("X-Apple-Session-ID", "1bd6ceeb-fffd-456c-a09c-996053a7a08c");
         var data = File.ReadAllBytes (file);
         // FIXME: change address to match your device
         wc.UploadData ("http://your.apple.tv:7000/photo", "PUT", data);
     }
 }
Example #13
0
    /// <summary>
    /// Private accessor for all GET and POST requests.
    /// </summary>
    /// <param name="url">Web url to be accessed.</param>
    /// <param name="post">Place POST request information here. If a GET request, use null. </param>
    /// <param name="attempts"># of attemtps before sending back an empty string.</param>
    /// <returns>Page HTML if access was successful, otherwise will return a blank string. </returns>
    private String getHtml(String url, String post, int attempts)
    {
        WebClient webClient = new WebClient();
            UTF8Encoding utfObj = new UTF8Encoding();
            byte[] reqHTML;

            while (attempts > 0)// Will keep trying to access until attempts reach zero.
            {
                try
                {
                    if (post != null) //If post is null, then no post request is required.
                        reqHTML = webClient.UploadData(url, "POST", System.Text.Encoding.ASCII.GetBytes(post));
                    else
                        reqHTML = webClient.DownloadData(url);
                    String input = utfObj.GetString(reqHTML);
                    return input;
                }
                catch (WebException e)
                {
                    errorLog.WriteMessage("Could not contact to " + url + "  -  " + e.Message);
                    Thread.Sleep(2000);
                }
                catch (ArgumentNullException e)
                {
                    errorLog.WriteMessage("Could not retrieve data from " + url + "  -  " + e.Message);
                    Thread.Sleep(2000);
                }
                attempts--;
            }
            return "";
    }
Example #14
0
    private JObject winkCallAPI(string url, string method = "", string sendcommand = "", bool requiresToken = true)
    {
        try
        {
            String responseString = string.Empty;
            JObject jsonResponse = new JObject();

            using (var xhr = new WebClient())
            {
                xhr.Headers[HttpRequestHeader.ContentType] = "application/json";

                if (requiresToken)
                    xhr.Headers.Add("Authorization", "Bearer " + myWink.WinkToken);

                byte[] result = null;

                if (String.IsNullOrWhiteSpace(sendcommand) && method.ToLower() != "post")
                {
                    result = xhr.DownloadData(url);
                }
                else
                {
                    byte[] data = Encoding.Default.GetBytes(sendcommand);
                    result = xhr.UploadData(url, method, data);
                }

                responseString = Encoding.Default.GetString(result);
            }

            if (responseString != null)
            {
                #if DEBUG
                if (url == "https://winkapi.quirky.com/users/me/wink_devices")
                {
                    if (myWink.winkUser.email.ToLower().Contains("trunzo"))
                    {
                        //Add Garage Door
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{\"garage_door_id\": \"8552\",\"name\": \"zTest Chamberlain\",\"locale\": \"en_us\",\"units\": {},\"created_at\": 1420250978,\"hidden_at\": null,\"capabilities\": {},\"subscription\": {\"pubnub\": {\"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\",\"channel\": \"af309d2e12b86bd1e5e63123db745dad703e46fb|garage_door-8552|user-123172\"}},\"user_ids\": [\"123172\"],\"triggers\": [],\"desired_state\": {\"position\": 1.0},\"manufacturer_device_model\": \"chamberlain_vgdo\",\"manufacturer_device_id\": \"1180839\",\"device_manufacturer\": \"chamberlain\",\"model_name\": \"MyQ Garage Door Controller\",\"upc_id\": \"26\",\"linked_service_id\": \"59900\",\"last_reading\": {\"connection\": true,\"connection_updated_at\": 1428535030.025161,\"position\": 1.0,\"position_updated_at\": 1428535020.76,\"position_opened\": \"N/A\",\"position_opened_updated_at\": 1428534916.709,\"battery\": 1.0,\"battery_updated_at\": 1428534350.3417819,\"fault\": false,\"fault_updated_at\": 1428534350.3417749,\"control_enabled\": true,\"control_enabled_updated_at\": 1428534350.3417563,\"desired_position\": 0.0,\"desired_position_updated_at\": 1428535030.0404377},\"lat_lng\": [33.162135,-97.090945],\"location\": \"\",\"order\": 0},");

                        //Add Honeywell Thermostat
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{\"thermostat_id\": \"27239\",\"name\": \"zTest Honeywell\",\"locale\": \"en_us\",\"units\": {\"temperature\": \"f\"},\"created_at\": 1419909349,\"hidden_at\": null,\"capabilities\": {},\"subscription\": {\"pubnub\": {\"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\",\"channel\": \"f5cb03e4101d1668ff7933a703a864b4984fce5a|thermostat-27239|user-123172\"}},\"user_ids\": [\"123172\",\"157050\"],\"triggers\": [],\"desired_state\": {\"mode\": \"heat_only\",\"powered\": true,\"min_set_point\": 20.0,\"max_set_point\": 22.777777777777779},\"manufacturer_device_model\": \"MANHATTAN\",\"manufacturer_device_id\": \"798165\",\"device_manufacturer\": \"honeywell\",\"model_name\": \"Honeywell Wi-Fi Smart Thermostat\",\"upc_id\": \"151\",\"hub_id\": null,\"local_id\": \"00D02D49A90A\",\"radio_type\": null,\"linked_service_id\": \"57563\",\"last_reading\": {\"connection\": true,\"connection_updated_at\": 1428536316.8312173,\"mode\": \"heat_only\",\"mode_updated_at\": 1428536316.8312581,\"powered\": true,\"powered_updated_at\": 1428536316.831265,\"min_set_point\": 20.0,\"min_set_point_updated_at\": 1428536316.8312485,\"max_set_point\": 22.777777777777779,\"max_set_point_updated_at\": 1428536316.8312287,\"temperature\": 22.777777777777779,\"temperature_updated_at\": 1428536316.8312783,\"external_temperature\": null,\"external_temperature_updated_at\": null,\"deadband\": 1.6666666666666667,\"deadband_updated_at\": 1428536316.831311,\"min_min_set_point\": 4.4444444444444446,\"min_min_set_point_updated_at\": 1428536316.8313046,\"max_min_set_point\": 29.444444444444443,\"max_min_set_point_updated_at\": 1428536316.8312914,\"min_max_set_point\": 16.666666666666668,\"min_max_set_point_updated_at\": 1428536316.8312984,\"max_max_set_point\": 37.222222222222221,\"max_max_set_point_updated_at\": 1428536316.831285,\"modes_allowed\": [\"auto\",\"cool_only\",\"heat_only\"],\"modes_allowed_updated_at\": 1428536316.8313177,\"units\": \"f\",\"units_updated_at\": 1428536316.8312719,\"desired_mode\": \"heat_only\",\"desired_mode_updated_at\": 1428365474.3775809,\"desired_powered\": true,\"desired_powered_updated_at\": 1424823532.9645114,\"desired_min_set_point\": 20.0,\"desired_min_set_point_updated_at\": 1428509375.1094887,\"desired_max_set_point\": 22.777777777777779,\"desired_max_set_point_updated_at\": 1428509375.109503},\"lat_lng\": [33.162074,-97.090928],\"location\": \"\",\"smart_schedule_enabled\": false},");

                        //Add Nest Thermostat
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{\"thermostat_id\": \"49534\",\"name\": \"zTest Nest\",\"locale\": \"en_us\",\"units\": {\"temperature\": \"f\"},\"created_at\": 1427241058,\"hidden_at\": null,\"capabilities\": {},\"subscription\": {\"pubnub\": {\"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\",\"channel\": \"0e67d43624e47b3633273f1236b7cde2c1823ac7|thermostat-49410|user-81926\"}},\"user_ids\": [\"81926\"],\"triggers\": [],\"desired_state\": {\"mode\": \"cool_only\",\"powered\": true,\"min_set_point\": 21.0,\"max_set_point\": 22.0,\"users_away\": false,\"fan_timer_active\": false},\"manufacturer_device_model\": \"nest\",\"manufacturer_device_id\": \"pHNukJTND3MHRBT9zks77kxx11Qobba_\",\"device_manufacturer\": \"nest\",\"model_name\": \"Learning Thermostat\",\"upc_id\": \"168\",\"hub_id\": null,\"local_id\": null,\"radio_type\": null,\"linked_service_id\": \"92972\",\"last_reading\": {\"connection\": true,\"connection_updated_at\": 1428516397.2914052,\"mode\": \"cool_only\",\"mode_updated_at\": 1428516397.2914376,\"powered\": true,\"powered_updated_at\": 1428516397.2914565,\"min_set_point\": 21.0,\"min_set_point_updated_at\": 1428461324.5980272,\"max_set_point\": 22.0,\"max_set_point_updated_at\": 1428516397.2914746,\"users_away\": false,\"users_away_updated_at\": 1428516397.2914917,\"fan_timer_active\": false,\"fan_timer_active_updated_at\": 1428516397.2914684,\"temperature\": 22.0,\"temperature_updated_at\": 1428516397.2914257,\"external_temperature\": null,\"external_temperature_updated_at\": null,\"deadband\": 1.5,\"deadband_updated_at\": 1428516397.2914317,\"min_min_set_point\": null,\"min_min_set_point_updated_at\": null,\"max_min_set_point\": null,\"max_min_set_point_updated_at\": null,\"min_max_set_point\": null,\"min_max_set_point_updated_at\": null,\"max_max_set_point\": null,\"max_max_set_point_updated_at\": null,\"modes_allowed\": [\"auto\",\"heat_only\",\"cool_only\"],\"modes_allowed_updated_at\": 1428516397.2914805,\"units\": \"f\",\"units_updated_at\": 1428516397.2914197,\"eco_target\": false,\"eco_target_updated_at\": 1428516397.2914433,\"manufacturer_structure_id\": \"kdCrRKp3UahHp8xWEoJBRYX9xnQWDsoU1sb5ej9Mp5Zb41WEIOKJtg\",\"manufacturer_structure_id_updated_at\": 1428516397.2914503,\"has_fan\": true,\"has_fan_updated_at\": 1428516397.2914622,\"fan_duration\": 0,\"fan_duration_updated_at\": 1428516397.2914863,\"last_error\": null,\"last_error_updated_at\": 1427241058.6980464,\"desired_mode\": \"cool_only\",\"desired_mode_updated_at\": 1427593066.90498,\"desired_powered\": true,\"desired_powered_updated_at\": 1428462838.6427567,\"desired_min_set_point\": 21.0,\"desired_min_set_point_updated_at\": 1428427791.3297703,\"desired_max_set_point\": 22.0,\"desired_max_set_point_updated_at\": 1428497187.9092989,\"desired_users_away\": false,\"desired_users_away_updated_at\": 1428440888.9921448,\"desired_fan_timer_active\": false,\"desired_fan_timer_active_updated_at\": 1427241058.6981435},\"lat_lng\": [null,null],\"location\": \"\",\"smart_schedule_enabled\": false},");

                        //Add Refuel
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{\"propane_tank_id\": \"6521\",\"name\": \"zTest Refuel\",\"locale\": \"en_us\",\"units\": {\"temperature\": \"f\"},\"created_at\": 1419569612,\"hidden_at\": null,\"capabilities\": {},\"subscription\": {\"pubnub\": {\"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\",\"channel\": \"5055752531a8aac104827ec4ba2a3366038ee15a|propane_tank-6521|user-123172\"}},\"user_ids\": [\"123172\",\"157050\"],\"triggers\": [],\"device_manufacturer\": \"quirky_ge\",\"model_name\": \"Refuel\",\"upc_id\": \"17\",\"last_reading\": {\"connection\": true,\"battery\": 0.52,\"remaining\": 0.5},\"lat_lng\": [33.162101,-97.090547],\"location\": \"76210\",\"mac_address\": \"0c2a6907025a\",\"serial\": \"ACAB00033589\",\"tare\": 18.0,\"tank_changed_at\": 1421352479},");

                        //Add Nest Protect
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{ \"smoke_detector_id\": \"10076\", \"name\": \"zTest Nest Protect\", \"locale\": \"en_us\", \"units\": {}, \"created_at\": 1419086573, \"hidden_at\": null, \"capabilities\": {}, \"subscription\": { \"pubnub\": { \"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\", \"channel\": \"5882005d3a98dbbd335c2cf778a6734557cd1f2f|smoke_detector-10076|user-145398\" } }, \"user_ids\": [ \"145398\" ], \"manufacturer_device_model\": \"nest\", \"manufacturer_device_id\": \"VpXN4GQ7MUD5QqV8vgvQOExx11Qobba_\", \"device_manufacturer\": \"nest\", \"model_name\": \"Smoke + Carbon Monoxide Detector\", \"upc_id\": \"170\", \"hub_id\": null, \"local_id\": null, \"radio_type\": null, \"linked_service_id\": \"50847\", \"last_reading\": { \"connection\": true, \"connection_updated_at\": 1428865904.1217248, \"battery\": 1.0, \"battery_updated_at\": 1428865904.1217616, \"co_detected\": false, \"co_detected_updated_at\": 1428865904.1217353, \"smoke_detected\": false, \"smoke_detected_updated_at\": 1428865904.1217477, \"test_activated\": null, \"test_activated_updated_at\": 1428855697.3881633, \"smoke_severity\": 0.0, \"smoke_severity_updated_at\": 1428865904.1217549, \"co_severity\": 0.0, \"co_severity_updated_at\": 1428865904.1217415 }, \"lat_lng\": [ null, null ], \"location\": \"\" },");

                        //Add Relay & Related
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{ \"hub_id\": \"132595\", \"name\": \"zTest Wink Relay\", \"locale\": \"en_us\", \"units\": {}, \"created_at\": 1428545678, \"hidden_at\": null, \"capabilities\": { \"oauth2_clients\": [ \"wink_project_one\" ] }, \"subscription\": { \"pubnub\": { \"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\", \"channel\": \"d9be1fe3abeb9fc46bec54a7cb62719a5a576c86|hub-132595|user-145398\" } }, \"user_ids\": [ \"145398\" ], \"triggers\": [], \"desired_state\": { \"pairing_mode\": null }, \"manufacturer_device_model\": \"wink_project_one\", \"manufacturer_device_id\": null, \"device_manufacturer\": \"wink\", \"model_name\": \"Wink Relay\", \"upc_id\": \"186\", \"last_reading\": { \"connection\": true, \"connection_updated_at\": 1428865074.9676549, \"agent_session_id\": \"9c99e3314c3a39f2eb9830a78d10684c\", \"agent_session_id_updated_at\": 1428855693.8299525, \"remote_pairable\": null, \"remote_pairable_updated_at\": null, \"updating_firmware\": false, \"updating_firmware_updated_at\": 1428855688.0774271, \"app_rootfs_version\": \"1.0.221\", \"app_rootfs_version_updated_at\": 1428855697.3881633, \"firmware_version\": \"1.0.221\", \"firmware_version_updated_at\": 1428855697.3881423, \"update_needed\": false, \"update_needed_updated_at\": 1428855697.3881698, \"mac_address\": \"B4:79:A7:0F:F7:DF\", \"mac_address_updated_at\": 1428855697.3881495, \"ip_address\": \"192.168.1.187\", \"ip_address_updated_at\": 1428855697.3881567, \"hub_version\": \"user\", \"hub_version_updated_at\": 1428855697.3881316, \"pairing_mode\": null, \"pairing_mode_updated_at\": 1428545678.0519505, \"desired_pairing_mode\": null, \"desired_pairing_mode_updated_at\": 1428545678.0519564 }, \"lat_lng\": [ null, null ], \"location\": \"\", \"configuration\": null, \"update_needed\": true, \"uuid\": \"9bb6a0d5-30f2-4bf7-8b37-d667c30e05bc\" },");
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{ \"binary_switch_id\": \"46401\", \"name\": \"zTest Relay Switch A\", \"locale\": \"en_us\", \"units\": {}, \"created_at\": 1428545701, \"hidden_at\": null, \"capabilities\": { \"configuration\": null }, \"subscription\": { \"pubnub\": { \"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\", \"channel\": \"bb1cb7a5d146cbc2cf09dca3655f684b2e24be89|binary_switch-46401|user-145398\" } }, \"user_ids\": [ \"145398\" ], \"triggers\": [], \"desired_state\": { \"powered\": false, \"powering_mode\": \"dumb\" }, \"manufacturer_device_model\": null, \"manufacturer_device_id\": null, \"device_manufacturer\": null, \"model_name\": null, \"upc_id\": null, \"gang_id\": \"6776\", \"hub_id\": \"132595\", \"local_id\": \"1\", \"radio_type\": \"project_one\", \"last_reading\": { \"connection\": true, \"connection_updated_at\": 1428855698.9869163, \"powered\": false, \"powered_updated_at\": 1428855698.9869256, \"powering_mode\": \"dumb\", \"powering_mode_updated_at\": 1428545815.5253267, \"consumption\": null, \"consumption_updated_at\": null, \"cost\": null, \"cost_updated_at\": null, \"budget_percentage\": null, \"budget_percentage_updated_at\": null, \"budget_velocity\": null, \"budget_velocity_updated_at\": null, \"summation_delivered\": null, \"summation_delivered_updated_at\": null, \"sum_delivered_multiplier\": null, \"sum_delivered_multiplier_updated_at\": null, \"sum_delivered_divisor\": null, \"sum_delivered_divisor_updated_at\": null, \"sum_delivered_formatting\": null, \"sum_delivered_formatting_updated_at\": null, \"sum_unit_of_measure\": null, \"sum_unit_of_measure_updated_at\": null, \"desired_powered\": false, \"desired_powered_updated_at\": 1428546752.8178129, \"desired_powering_mode\": \"dumb\", \"desired_powering_mode_updated_at\": 1428545815.5253191 }, \"current_budget\": null, \"lat_lng\": [ 0.0, 0.0 ], \"location\": \"\", \"order\": 0 },");
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{ \"binary_switch_id\": \"30320\", \"name\": \"zTest Relay Switch B\", \"locale\": \"en_us\", \"units\": {}, \"created_at\": 1422813943, \"hidden_at\": null, \"capabilities\": {},\"subscription\": {\"pubnub\": {\"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\",\"channel\": \"8afe2bdfa540e4459b510bff44db636388afea88|binary_switch-30320|user-186645\"}},\"user_ids\": [\"186645\"],\"triggers\": [],\"desired_state\": {\"powered\": false,\"powering_mode\": \"none\"},\"manufacturer_device_model\": null,\"manufacturer_device_id\": null,\"device_manufacturer\": null,\"model_name\": null,\"upc_id\": null,\"gang_id\": \"2997\",\"hub_id\": \"98045\",\"local_id\": \"2\",\"radio_type\": \"project_one\",\"last_reading\": {\"connection\": true,\"connection_updated_at\": 1429016828.833034,\"powered\": false,\"powered_updated_at\": 1429016828.8330438,\"powering_mode\": \"none\",\"powering_mode_updated_at\": 1422824216.9928842,\"consumption\": null,\"consumption_updated_at\": null,\"cost\": null,\"cost_updated_at\": null,\"budget_percentage\": null,\"budget_percentage_updated_at\": null,\"budget_velocity\": null,\"budget_velocity_updated_at\": null,\"summation_delivered\": null,\"summation_delivered_updated_at\": null,\"sum_delivered_multiplier\": null,\"sum_delivered_multiplier_updated_at\": null,\"sum_delivered_divisor\": null,\"sum_delivered_divisor_updated_at\": null,\"sum_delivered_formatting\": null,\"sum_delivered_formatting_updated_at\": null,\"sum_unit_of_measure\": null,\"sum_unit_of_measure_updated_at\": null,\"desired_powered\": false,\"desired_powered_updated_at\": 1422824138.418901,\"desired_powering_mode\": \"none\",\"desired_powering_mode_updated_at\": 1422824216.9928727},\"current_budget\": null,\"lat_lng\": [0.0,0.0],\"location\": \"\",\"order\": 0},");
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{ \"button_id\": \"13333\", \"name\": \"zTest Smart Button 1\", \"locale\": \"en_us\", \"units\": {}, \"created_at\": 1428545701, \"hidden_at\": null, \"capabilities\": {}, \"subscription\": { \"pubnub\": { \"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\", \"channel\": \"2894740376a764e392d566474aac56f634c3731f|button-13333|user-145398\" } }, \"user_ids\": [ \"145398\" ], \"manufacturer_device_model\": null, \"manufacturer_device_id\": null, \"device_manufacturer\": null, \"model_name\": null, \"upc_id\": null, \"gang_id\": \"6776\", \"hub_id\": \"132595\", \"local_id\": \"4\", \"radio_type\": \"project_one\", \"last_reading\": { \"connection\": true, \"connection_updated_at\": 1428855697.7729235, \"pressed\": false, \"pressed_updated_at\": 1428855697.7729335, \"long_pressed\": null, \"long_pressed_updated_at\": null }, \"lat_lng\": [ null, null ], \"location\": \"\" },");
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{ \"button_id\": \"13334\", \"name\": \"zTest Smart Button 2\", \"locale\": \"en_us\", \"units\": {}, \"created_at\": 1428545701, \"hidden_at\": null, \"capabilities\": {}, \"subscription\": { \"pubnub\": { \"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\", \"channel\": \"51c9e90c1b352231a0ce9bdbfa1295c052af91f2|button-13334|user-145398\" } }, \"user_ids\": [ \"145398\" ], \"manufacturer_device_model\": null, \"manufacturer_device_id\": null, \"device_manufacturer\": null, \"model_name\": null, \"upc_id\": null, \"gang_id\": \"6776\", \"hub_id\": \"132595\", \"local_id\": \"5\", \"radio_type\": \"project_one\", \"last_reading\": { \"connection\": true, \"connection_updated_at\": 1428855697.9626672, \"pressed\": false, \"pressed_updated_at\": 1428855697.962677, \"long_pressed\": null, \"long_pressed_updated_at\": null }, \"lat_lng\": [ null, null ], \"location\": \"\" },");
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{ \"gang_id\": \"6776\", \"name\": \"zTest Gang\", \"locale\": \"en_us\", \"units\": {}, \"created_at\": 1428545678, \"hidden_at\": null, \"capabilities\": {}, \"subscription\": { \"pubnub\": { \"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\", \"channel\": \"1d8877fe2c53439330ef7e72548c6fa38e111420|gang-6776|user-145398\" } }, \"user_ids\": [ \"145398\" ], \"desired_state\": {}, \"manufacturer_device_model\": \"wink_project_one\", \"manufacturer_device_id\": null, \"device_manufacturer\": null, \"model_name\": null, \"upc_id\": null, \"hub_id\": \"132595\", \"local_id\": null, \"radio_type\": null, \"last_reading\": { \"connection\": true, \"connection_updated_at\": 1428545678.122422 }, \"lat_lng\": [ null, null ], \"location\": \"\" },");

                        //Spotter
                                responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{\"last_event\":{\"brightness_occurred_at\":1428961404.2836313,\"loudness_occurred_at\":1427547964.9292188,\"vibration_occurred_at\":1428879300.9600453},\"sensor_threshold_events\":[],\"sensor_pod_id\":\"40794\",\"name\":\"zTest Spotter\",\"locale\":\"en_us\",\"units\":{\"temperature\":\"f\"},\"created_at\":1422657639,\"hidden_at\":null,\"capabilities\":{\"sensor_types\":[{\"type\":\"percentage\",\"field\":\"battery\"},{\"type\":\"percentage\",\"field\":\"brightness\"},{\"type\":\"boolean\",\"field\":\"external_power\"},{\"type\":\"integer_percentage\",\"field\":\"humidity\"},{\"type\":\"percentage\",\"field\":\"loudness\"},{\"type\":\"float\",\"field\":\"temperature\"},{\"type\":\"boolean\",\"field\":\"vibration\"}]},\"subscription\":{\"pubnub\":{\"subscribe_key\":\"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\",\"channel\":\"959bda140ade2f77ded3fd968bfac2242489175e|sensor_pod-40794|user-186645\"}},\"user_ids\":[\"186645\"],\"triggers\":[],\"desired_state\":{},\"manufacturer_device_model\":\"quirky_ge_spotter\",\"manufacturer_device_id\":null,\"device_manufacturer\":\"quirky_ge\",\"model_name\":\"Spotter\",\"upc_id\":\"25\",\"gang_id\":null,\"hub_id\":null,\"local_id\":null,\"radio_type\":null,\"last_reading\":{\"connection\":true,\"connection_updated_at\":1428969581.0099306,\"agent_session_id\":null,\"agent_session_id_updated_at\":1425384214.8524168,\"battery\":0.98,\"battery_updated_at\":1428969581.0099251,\"brightness\":1.0,\"brightness_updated_at\":1428969581.0098875,\"external_power\":true,\"external_power_updated_at\":1428969581.0098965,\"humidity\":35,\"humidity_updated_at\":1428969581.0099025,\"loudness\":0.0,\"loudness_updated_at\":1428969581.0099192,\"temperature\":19.0,\"temperature_updated_at\":1428969581.0099139,\"vibration\":false,\"vibration_updated_at\":1428969581.0099082,\"brightness_true\":\"N/A\",\"brightness_true_updated_at\":1428961404.2836313,\"loudness_true\":\"N/A\",\"loudness_true_updated_at\":1427547964.9292188,\"vibration_true\":\"N/A\",\"vibration_true_updated_at\":1428879300.9600453},\"lat_lng\":[0.0,0.0],\"location\":\"\",\"mac_address\":\"0c2a690656b3\",\"serial\":\"ABAB00029469\",\"uuid\":\"005f5493-2ab6-46fa-ab7d-f2932c37dd4a\"},");

                        //Rachio Iro
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{\"sprinkler_id\": \"1483\",\"name\": \"Sprinkler\",\"locale\": \"en_us\",\"units\": {},\"created_at\": 1429295028,\"hidden_at\": null,\"capabilities\": {},\"subscription\": {\"pubnub\": {\"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\",\"channel\": \"ecbd8151da8524635b2dfd777c4f55f33a042285|sprinkler-1483|user-186645\"}},\"user_ids\": [\"186645\"],\"desired_state\": {\"master_valve\": false,\"rain_sensor\": false,\"schedule_enabled\": false,\"run_zone_indices\": [],\"run_zone_durations\": []},\"manufacturer_device_model\": \"rachio_iro\",\"manufacturer_device_id\": \"b26d4e70-f4df-481a-9149-c9bac4c3a09e\",\"device_manufacturer\": \"rachio\",\"model_name\": \"Iro\",\"upc_id\": \"152\",\"linked_service_id\": \"100792\",\"last_reading\": {\"connection\": true,\"connection_updated_at\": 1429477160.725,\"master_valve\": false,\"master_valve_updated_at\": 1429477160.725,\"rain_sensor\": false,\"rain_sensor_updated_at\": 1429477160.725,\"schedule_enabled\": false,\"schedule_enabled_updated_at\": 1429477160.725,\"run_zone_indices\": [],\"run_zone_indices_updated_at\": 1429361044.5683227,\"run_zone_durations\": [],\"run_zone_durations_updated_at\": 1429361044.5683227,\"desired_master_valve\": false,\"desired_master_valve_updated_at\": 1429361044.6298194,\"desired_rain_sensor\": false,\"desired_rain_sensor_updated_at\": 1429361042.534966,\"desired_schedule_enabled\": false,\"desired_schedule_enabled_updated_at\": 1429361044.6298397,\"desired_run_zone_indices\": [],\"desired_run_zone_indices_updated_at\": 1429361042.5349822,\"desired_run_zone_durations\": [],\"desired_run_zone_durations_updated_at\": 1429361042.5349896},\"lat_lng\": [41.38983,-81.42602],\"location\": \"\",\"zones\": [{\"name\": \"Top Driveway\",\"desired_state\": {\"enabled\": true,\"enabled_updated_at\": 1429361044.6298468,\"shade\": \"none\",\"shade_updated_at\": 1429361044.6298535,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429361044.6298602,\"soil\": \"top_soil\",\"soil_updated_at\": 1429361044.6298668,\"slope\": \"flat\",\"slope_updated_at\": 1429361044.629873,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429361044.6298814},\"last_reading\": {\"enabled\": true,\"enabled_updated_at\": 1429477160.725,\"shade\": \"none\",\"shade_updated_at\": 1429477160.725,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429477160.725,\"soil\": \"top_soil\",\"soil_updated_at\": 1429477160.725,\"slope\": \"flat\",\"slope_updated_at\": 1429477160.725,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429477160.725,\"powered\": false,\"powered_updated_at\": 1429361044.5683227},\"zone_index\": 0,\"zone_id\": \"12501\",\"parent_object_type\": \"sprinkler\",\"parent_object_id\": \"1483\"},{\"name\": \"Driveway Bottom\",\"desired_state\": {\"enabled\": true,\"enabled_updated_at\": 1429361044.6298881,\"shade\": \"none\",\"shade_updated_at\": 1429361044.6298945,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429361044.6299007,\"soil\": \"top_soil\",\"soil_updated_at\": 1429361044.6299071,\"slope\": \"flat\",\"slope_updated_at\": 1429361044.6299136,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429361044.6299202},\"last_reading\": {\"enabled\": true,\"enabled_updated_at\": 1429477160.725,\"shade\": \"none\",\"shade_updated_at\": 1429477160.725,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429477160.725,\"soil\": \"top_soil\",\"soil_updated_at\": 1429477160.725,\"slope\": \"flat\",\"slope_updated_at\": 1429477160.725,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429477160.725,\"powered\": false,\"powered_updated_at\": 1429361044.5683227},\"zone_index\": 1,\"zone_id\": \"12502\",\"parent_object_type\": \"sprinkler\",\"parent_object_id\": \"1483\"},{\"name\": \"Tree Lawn\",\"desired_state\": {\"enabled\": true,\"enabled_updated_at\": 1429361044.6299269,\"shade\": \"none\",\"shade_updated_at\": 1429361044.6299338,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429361044.6299408,\"soil\": \"top_soil\",\"soil_updated_at\": 1429361044.6299474,\"slope\": \"flat\",\"slope_updated_at\": 1429361044.6299543,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429361044.629961},\"last_reading\": {\"enabled\": true,\"enabled_updated_at\": 1429477160.725,\"shade\": \"none\",\"shade_updated_at\": 1429477160.725,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429477160.725,\"soil\": \"top_soil\",\"soil_updated_at\": 1429477160.725,\"slope\": \"flat\",\"slope_updated_at\": 1429477160.725,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429477160.725,\"powered\": false,\"powered_updated_at\": 1429361044.5683227},\"zone_index\": 2,\"zone_id\": \"12503\",\"parent_object_type\": \"sprinkler\",\"parent_object_id\": \"1483\"},{\"name\": \"Back Right\",\"desired_state\": {\"enabled\": false,\"enabled_updated_at\": 1429361044.6299675,\"shade\": \"none\",\"shade_updated_at\": 1429361044.6299734,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429361044.6299799,\"soil\": \"top_soil\",\"soil_updated_at\": 1429361044.6299863,\"slope\": \"flat\",\"slope_updated_at\": 1429361044.6299949,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429361044.6300077},\"last_reading\": {\"enabled\": false,\"enabled_updated_at\": 1429477160.725,\"shade\": \"none\",\"shade_updated_at\": 1429477160.725,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429477160.725,\"soil\": \"top_soil\",\"soil_updated_at\": 1429477160.725,\"slope\": \"flat\",\"slope_updated_at\": 1429477160.725,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429477160.725,\"powered\": false,\"powered_updated_at\": 1429361044.5683227},\"zone_index\": 3,\"zone_id\": \"12504\",\"parent_object_type\": \"sprinkler\",\"parent_object_id\": \"1483\"},{\"name\": \"Mailbox\",\"desired_state\": {\"enabled\": true,\"enabled_updated_at\": 1429361044.6300216,\"shade\": \"none\",\"shade_updated_at\": 1429361044.6300349,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429361044.6300464,\"soil\": \"top_soil\",\"soil_updated_at\": 1429361044.630054,\"slope\": \"flat\",\"slope_updated_at\": 1429361044.6300609,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429361044.6300678},\"last_reading\": {\"enabled\": true,\"enabled_updated_at\": 1429477160.725,\"shade\": \"none\",\"shade_updated_at\": 1429477160.725,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429477160.725,\"soil\": \"top_soil\",\"soil_updated_at\": 1429477160.725,\"slope\": \"flat\",\"slope_updated_at\": 1429477160.725,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429477160.725,\"powered\": false,\"powered_updated_at\": 1429361044.5683227},\"zone_index\": 4,\"zone_id\": \"12505\",\"parent_object_type\": \"sprinkler\",\"parent_object_id\": \"1483\"},{\"name\": \"Back Center\",\"desired_state\": {\"enabled\": true,\"enabled_updated_at\": 1429361044.6300743,\"shade\": \"none\",\"shade_updated_at\": 1429361044.6300812,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429361044.6300881,\"soil\": \"top_soil\",\"soil_updated_at\": 1429361044.6300948,\"slope\": \"flat\",\"slope_updated_at\": 1429361044.6301012,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429361044.6301079},\"last_reading\": {\"enabled\": true,\"enabled_updated_at\": 1429477160.725,\"shade\": \"none\",\"shade_updated_at\": 1429477160.725,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429477160.725,\"soil\": \"top_soil\",\"soil_updated_at\": 1429477160.725,\"slope\": \"flat\",\"slope_updated_at\": 1429477160.725,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429477160.725,\"powered\": false,\"powered_updated_at\": 1429361044.5683227},\"zone_index\": 5,\"zone_id\": \"12506\",\"parent_object_type\": \"sprinkler\",\"parent_object_id\": \"1483\"},{\"name\": \"Back Left\",\"desired_state\": {\"enabled\": true,\"enabled_updated_at\": 1429361044.6301141,\"shade\": \"none\",\"shade_updated_at\": 1429361044.6301203,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429361044.6301262,\"soil\": \"top_soil\",\"soil_updated_at\": 1429361044.6301327,\"slope\": \"flat\",\"slope_updated_at\": 1429361044.6301389,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429361044.6301456},\"last_reading\": {\"enabled\": true,\"enabled_updated_at\": 1429477160.725,\"shade\": \"none\",\"shade_updated_at\": 1429477160.725,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429477160.725,\"soil\": \"top_soil\",\"soil_updated_at\": 1429477160.725,\"slope\": \"flat\",\"slope_updated_at\": 1429477160.725,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429477160.725,\"powered\": false,\"powered_updated_at\": 1429361044.5683227},\"zone_index\": 6,\"zone_id\": \"12507\",\"parent_object_type\": \"sprinkler\",\"parent_object_id\": \"1483\"},{\"name\": \"Zone 8\",\"desired_state\": {\"enabled\": false,\"enabled_updated_at\": 1429361044.630152,\"shade\": \"none\",\"shade_updated_at\": 1429361044.6301584,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429361044.6301646,\"soil\": \"top_soil\",\"soil_updated_at\": 1429361044.6301739,\"slope\": \"flat\",\"slope_updated_at\": 1429361044.6301811,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429361044.6301878},\"last_reading\": {\"enabled\": false,\"enabled_updated_at\": 1429477160.725,\"shade\": \"none\",\"shade_updated_at\": 1429477160.725,\"nozzle\": \"fixed_spray_head\",\"nozzle_updated_at\": 1429477160.725,\"soil\": \"top_soil\",\"soil_updated_at\": 1429477160.725,\"slope\": \"flat\",\"slope_updated_at\": 1429477160.725,\"vegetation\": \"grass\",\"vegetation_updated_at\": 1429477160.725,\"powered\": false,\"powered_updated_at\": 1429361044.5683227},\"zone_index\": 7,\"zone_id\": \"12508\",\"parent_object_type\": \"sprinkler\",\"parent_object_id\": \"1483\"}]},");

                        //Ascend
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{ \"garage_door_id\": \"16896\", \"name\": \"zTest Ascend Garage Door\", \"locale\": \"en_us\", \"units\": {}, \"created_at\": 1430344326, \"hidden_at\": null, \"capabilities\": {}, \"subscription\": { \"pubnub\": { \"subscribe_key\": \"sub-c-f7bf7f7e-0542-11e3-a5e8-02ee2ddab7fe\", \"channel\": \"9fe350e72a807190df334cd839a00992f59446b2|garage_door-16896|user-145398\" } }, \"user_ids\": [ \"145398\" ], \"triggers\": [], \"desired_state\": { \"position\": 0.0, \"laser\": false, \"calibration_enabled\": false }, \"manufacturer_device_model\": \"quirky_ge_ascend\", \"manufacturer_device_id\": null, \"device_manufacturer\": \"quirky_ge\", \"model_name\": \"Ascend\", \"upc_id\": \"182\", \"linked_service_id\": null, \"last_reading\": { \"connection\": true, \"connection_updated_at\": 1430362778.3658881, \"position\": 0.0, \"position_updated_at\": 1430362778.3658676, \"position_opened\": \"N/A\", \"position_opened_updated_at\": 1430351386.88027, \"battery\": null, \"battery_updated_at\": null, \"fault\": false, \"fault_updated_at\": 1430362778.3658946, \"control_enabled\": null, \"control_enabled_updated_at\": null, \"laser\": false, \"laser_updated_at\": 1430362778.3658564, \"buzzer\": null, \"buzzer_updated_at\": null, \"led\": null, \"led_updated_at\": null, \"moving\": null, \"moving_updated_at\": null, \"calibrated\": true, \"calibrated_updated_at\": 1430362778.3658812, \"calibration_enabled\": false, \"calibration_enabled_updated_at\": 1430362778.3658745, \"last_error\": null, \"last_error_updated_at\": 1430362778.3659008, \"desired_position\": 0.0, \"desired_position_updated_at\": 1430362531.397609, \"desired_laser\": false, \"desired_laser_updated_at\": 1430345748.1740961, \"desired_calibration_enabled\": false, \"desired_calibration_enabled_updated_at\": 1430345759.9318135 }, \"lat_lng\": [ 41.675863, -81.287492 ], \"location\": \"44060\", \"mac_address\": null, \"serial\": \"20000c2a69088729\", \"order\": null},");

                        //T
                        //        responseString = responseString.Replace("{\"data\":[", "{\"data\":[" + "{ \"last_event\" : { \"brightness_occurred_at\" : null, \"loudness_occurred_at\" : null, \"vibration_occurred_at\" : null }, \"sensor_pod_id\" : \"53479\", \"name\" : \"Bedroom Sensor\", \"locale\" : \"en_us\", \"units\" : {}, \"created_at\" : 1427985576, \"hidden_at\" : null, \"capabilities\" : { \"sensor_types\" : [{ \"field\" : \"motion\", \"type\" : \"boolean\" } ] }, \"triggers\" : [], \"desired_state\" : {}, \"manufacturer_device_model\" : \"ecolink_pir_zwavve2\", \"manufacturer_device_id\" : null, \"device_manufacturer\" : \"Ecolink\", \"model_name\" : \"Motion Sensor\", \"upc_id\" : \"173\", \"gang_id\" : null, \"hub_id\" : \"45262\", \"local_id\" : \"19\", \"radio_type\" : \"zwave\", \"last_reading\" : { \"connection\" : true, \"connection_updated_at\" : 1431625783.7867568, \"agent_session_id\" : \"FALSE\", \"agent_session_id_updated_at\" : 1431625783.7867672, \"motion\" : true, \"motion_updated_at\" : 1431625783.7867749, \"motion_true\" : \"N/A\", \"motion_true_updated_at\" : 1431625783.7867839, \"agent_session_id_changed_at\" : 1431625783.7867672, \"motion_changed_at\" : 1431625783.7867749 }, \"lat_lng\" : [ 39.024424, -77.038657 ], \"location\" : \"\", \"uuid\" : \"e9eaeaf1-2ce4-46d4-adb6-6f3f560a0594\" }, { \"last_event\" : { \"brightness_occurred_at\" : null, \"loudness_occurred_at\" : null, \"vibration_occurred_at\" : null }, \"sensor_pod_id\" : \"53481\", \"name\" : \"Bar sensor\", \"locale\" : \"en_us\", \"units\" : {}, \"created_at\" : 1427985745, \"hidden_at\" : null, \"capabilities\" : { \"sensor_types\" : [{ \"field\" : \"motion\", \"type\" : \"boolean\" } ] }, \"triggers\" : [], \"desired_state\" : {}, \"manufacturer_device_model\" : \"ecolink_pir_zwavve2\", \"manufacturer_device_id\" : null, \"device_manufacturer\" : \"Ecolink\", \"model_name\" : \"Motion Sensor\", \"upc_id\" : \"173\", \"gang_id\" : null, \"hub_id\" : \"45262\", \"local_id\" : \"21\", \"radio_type\" : \"zwave\", \"last_reading\" : { \"connection\" : true, \"connection_updated_at\" : 1431626950.371877, \"agent_session_id\" : \"FALSE\", \"agent_session_id_updated_at\" : 1431626950.3718965, \"motion\" : false, \"motion_updated_at\" : 1431626950.3719103, \"motion_true\" : \"N/A\", \"motion_true_updated_at\" : 1431626950.3719225, \"agent_session_id_changed_at\" : 1431626950.3718965, \"motion_changed_at\" : 1431626950.3719103 }, \"lat_lng\" : [ 39.024424, -77.038657 ], \"location\" : \"\", \"uuid\" : \"6e4fb2d0-0c36-4a20-8da4-dd2250e55d6a\" }, { \"last_event\" : { \"brightness_occurred_at\" : null, \"loudness_occurred_at\" : null, \"vibration_occurred_at\" : null }, \"sensor_pod_id\" : \"60402\", \"name\" : \"Basement Door\", \"locale\" : \"en_us\", \"units\" : {}, \"created_at\" : 1430514447, \"hidden_at\" : null, \"capabilities\" : { \"sensor_types\" : [{ \"field\" : \"opened\", \"type\" : \"boolean\" }, { \"field\" : \"battery\", \"type\" : \"percentage\" }, { \"field\" : \"tamper_detected\", \"type\" : \"boolean\" } ], \"polling_interval\" : 4200, \"home_security_device\" : true, \"offline_notification\" : true }, \"triggers\" : [], \"desired_state\" : {}, \"manufacturer_device_model\" : \"quirky_ge_tripper\", \"manufacturer_device_id\" : null, \"device_manufacturer\" : \"quirky_ge\", \"model_name\" : \"Tripper\", \"upc_id\" : \"184\", \"gang_id\" : null, \"hub_id\" : \"45262\", \"local_id\" : \"34\", \"radio_type\" : \"zigbee\", \"last_reading\" : { \"connection\" : true, \"connection_updated_at\" : 1431626601.5417626, \"agent_session_id\" : null, \"agent_session_id_updated_at\" : 1430514451.8775995, \"firmware_version\" : \"1.8b00 / 5.1b21\", \"firmware_version_updated_at\" : 1431626601.5417826, \"firmware_date_code\" : \"20150120\", \"firmware_date_code_updated_at\" : 1431626601.5417743, \"opened\" : false, \"opened_updated_at\" : 1431626601.541836, \"battery\" : 1.0, \"battery_updated_at\" : 1431626601.5418434, \"tamper_detected\" : false, \"tamper_detected_updated_at\" : 1431626601.5418506, \"tamper_detected_true\" : null, \"tamper_detected_true_updated_at\" : null, \"battery_voltage\" : 29, \"battery_voltage_updated_at\" : 1431626601.54179, \"battery_alarm_mask\" : 15, \"battery_alarm_mask_updated_at\" : 1431626601.5417976, \"battery_voltage_min_threshold\" : 24, \"battery_voltage_min_threshold_updated_at\" : 1431626601.5418057, \"battery_voltage_threshold_1\" : 24, \"battery_voltage_threshold_1_updated_at\" : 1431626601.5418136, \"battery_voltage_threshold_2\" : 24, \"battery_voltage_threshold_2_updated_at\" : 1431626601.5418212, \"battery_voltage_threshold_3\" : 25, \"battery_voltage_threshold_3_updated_at\" : 1431626601.5418289, \"opened_changed_at\" : 1431626601.541836, \"battery_voltage_changed_at\" : 1431549393.1340518 }, \"lat_lng\" : [ 39.024242, -77.038966 ], \"location\" : \"\", \"uuid\" : \"52d5f095-6fc1-4256-8f4e-ce3c1d8b9215\" }, { \"last_event\" : { \"brightness_occurred_at\" : null, \"loudness_occurred_at\" : null, \"vibration_occurred_at\" : null }, \"sensor_pod_id\" : \"60965\", \"name\" : \"Front door\", \"locale\" : \"en_us\", \"units\" : {}, \"created_at\" : 1430666191, \"hidden_at\" : null, \"capabilities\" : { \"sensor_types\" : [{ \"field\" : \"opened\", \"type\" : \"boolean\" }, { \"field\" : \"battery\", \"type\" : \"percentage\" }, { \"field\" : \"tamper_detected\", \"type\" : \"boolean\" } ], \"polling_interval\" : 4200, \"home_security_device\" : true, \"offline_notification\" : true }, \"triggers\" : [], \"desired_state\" : {}, \"manufacturer_device_model\" : \"quirky_ge_tripper\", \"manufacturer_device_id\" : null, \"device_manufacturer\" : \"quirky_ge\", \"model_name\" : \"Tripper\", \"upc_id\" : \"184\", \"gang_id\" : null, \"hub_id\" : \"45262\", \"local_id\" : \"35\", \"radio_type\" : \"zigbee\", \"last_reading\" : { \"connection\" : true, \"connection_updated_at\" : 1431619864.8199573, \"agent_session_id\" : null, \"agent_session_id_updated_at\" : 1430666193.5535953, \"firmware_version\" : \"1.8b00 / 5.1b21\", \"firmware_version_updated_at\" : 1431619864.8199759, \"firmware_date_code\" : \"20150120\", \"firmware_date_code_updated_at\" : 1431619864.8199678, \"opened\" : true, \"opened_updated_at\" : 1431619864.8200295, \"battery\" : 1.0, \"battery_updated_at\" : 1431619864.8200362, \"tamper_detected\" : false, \"tamper_detected_updated_at\" : 1431619864.8200431, \"tamper_detected_true\" : \"N/A\", \"tamper_detected_true_updated_at\" : 1430666193.5537961, \"battery_voltage\" : 28, \"battery_voltage_updated_at\" : 1431619864.819983, \"battery_alarm_mask\" : 15, \"battery_alarm_mask_updated_at\" : 1431619864.8199911, \"battery_voltage_min_threshold\" : 24, \"battery_voltage_min_threshold_updated_at\" : 1431619864.819999, \"battery_voltage_threshold_1\" : 24, \"battery_voltage_threshold_1_updated_at\" : 1431619864.8200069, \"battery_voltage_threshold_2\" : 24, \"battery_voltage_threshold_2_updated_at\" : 1431619864.820015, \"battery_voltage_threshold_3\" : 25, \"battery_voltage_threshold_3_updated_at\" : 1431619864.8200226, \"opened_changed_at\" : 1431569313.1120057, \"battery_voltage_changed_at\" : 1431535108.6598671 }, \"lat_lng\" : [ 39.024228, -77.038927 ], \"location\" : \"\", \"uuid\" : \"d396485b-4125-4e0b-8891-c847618b0d0c\" },");
                    }
                }
                #endif
                jsonResponse = JObject.Parse(responseString);
                if (jsonResponse != null)
                {
                    return jsonResponse;
                }
            }
        }
        catch (Exception ex)
        {
            string em = ex.Message;
            if (em.Contains("404"))
                return JObject.Parse("{\"error\":404}");
        }
        return null;
    }