var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://developer.lametric.com/api/V1/dev/widget/update/com.lametric.153212d2df2b9492a5502dd876eac046/2");
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://developer.lametric.com/api/V1/dev/widget/update/com.lametric.153212d2df2b9492a5502dd876eac046/2");
Celestino Galán Couto
Could someone tell me what do I need to "make" a push server?
or to push data with my (domain hosted) server?
I mean that my server automaticaly execute (some) code in order to send push data...
Which technology do I need?
thank you everybody
you have to generate a http Post request to the lametric servers.
I am a .net developer her is some sample code in C#
lblErr.Text = ""; string authInfo = "Auth token from la Metric"; string url = "https://developer.lametric.com/api/V1/dev/widget/update/com.lametric.xxxxxxxxFrom La Metricxxxxxxxxxxxxxx";
string data = string.Format("{{\"frames\": [{{ \"index\": 0, \"text\": \"{0}\", \"icon\": \"i555\" }}, {{ \"index\": 1, \"text\": \"{1}\", \"icon\": \"a230\" }}, {{ \"index\": 2, \"text\": \"{2}\", \"icon\": \"a112\" }} ] }}", txtMessage.Text,txtMessage.Text,txtMessage.Text);
try {
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://developer.lametric.com/api/V1/dev/widget/update/com.lametric.153212d2df2b9492a5502dd876eac046/2");
httpWebRequest.Accept = "application/json"; httpWebRequest.Headers.Add("X-Access-Token", authInfo); httpWebRequest.Headers.Add("Cache-Control", "no-cache"); httpWebRequest.Host = "developer.lametric.com";
httpWebRequest.ContentType = "text/json";
httpWebRequest.ContentLength = data.Length;
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(string.Format("{0}", data));
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
}
catch (Exception ex)
{
lblErr.Text = ex.Message;
}
Bill D
you have to generate a http Post request to the lametric servers.
I am a .net developer her is some sample code in C#
lblErr.Text = ""; string authInfo = "Auth token from la Metric"; string url = "https://developer.lametric.com/api/V1/dev/widget/update/com.lametric.xxxxxxxxFrom La Metricxxxxxxxxxxxxxx";
string data = string.Format("{{\"frames\": [{{ \"index\": 0, \"text\": \"{0}\", \"icon\": \"i555\" }}, {{ \"index\": 1, \"text\": \"{1}\", \"icon\": \"a230\" }}, {{ \"index\": 2, \"text\": \"{2}\", \"icon\": \"a112\" }} ] }}", txtMessage.Text,txtMessage.Text,txtMessage.Text);
try {
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://developer.lametric.com/api/V1/dev/widget/update/com.lametric.153212d2df2b9492a5502dd876eac046/2");
httpWebRequest.Accept = "application/json"; httpWebRequest.Headers.Add("X-Access-Token", authInfo); httpWebRequest.Headers.Add("Cache-Control", "no-cache"); httpWebRequest.Host = "developer.lametric.com";
httpWebRequest.ContentType = "text/json";
httpWebRequest.ContentLength = data.Length;
httpWebRequest.Method = "POST";
using (var streamWriter = new StreamWriter(httpWebRequest.GetRequestStream()))
{
streamWriter.Write(string.Format("{0}", data));
streamWriter.Flush();
streamWriter.Close();
}
var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
var result = streamReader.ReadToEnd();
}
}
catch (Exception ex)
{
lblErr.Text = ex.Message;
}
1 person likes this
-
How to pull data from external site to display?
-
nodejs request "gets acces denied"
-
curl to python for eventghost
-
Push text from Eventghost to LaMetric via python
-
Basic API pull and json parse example....
-
A guide for starting an app?
-
A small wrapper to push your just created JIRA issues to your LaMetric.
-
Simple project to push home consumption data to be shown on a Lametric device
-
Interface to have Slack send messages to a LaMetric Time
-
Very simple module to push frames to LaMetric
See all 149 topics