Hello
Someone as an exemple to push data to lametric in PHP
The sample in JSON is
curl -X POST \
-H "Accept: application/json" \
-H "X-Access-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Cache-Control: no-cache" \
-d '{
"frames": [
{
"index": 0,
"goalData": {
"start": 100,
"current": 84,
"end": 75,
"unit": "Kg"
},
"icon": "i173"
}
]
}' \
https://developer.lametric.com/api/V1/dev/widget/update/com.lametric.xxxxxxxxxxxxxx
in red the data i want push
Tank's for your help
Cyril
This should do it:
<?php
$url = "LAMETRIC_ENDPOINT_URL";
$frames = array(
"frames" => array(
array(
'index' => 0,
'goalData' => array(
'start' => 100,
'current' => 84,
'end' => 75,
'unit' => 'Kg'
)
);
$curl = curl_init();
$headers = array(
"Accept: application/json",
"X-Access-Token: YOUR_ACCESS_TOKEN",
"Cache-Control: no-cache",
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($frames));
$response = curl_exec($curl);
curl_close($curl);
?>
I am asking to myself, how to do this in PHP? I try to do this with curl but I don't get it.
Cyril
Hello
Someone as an exemple to push data to lametric in PHP
The sample in JSON is
curl -X POST \
-H "Accept: application/json" \
-H "X-Access-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
-H "Cache-Control: no-cache" \
-d '{
"frames": [
{
"index": 0,
"goalData": {
"start": 100,
"current": 84,
"end": 75,
"unit": "Kg"
},
"icon": "i173"
}
]
}' \
https://developer.lametric.com/api/V1/dev/widget/update/com.lametric.xxxxxxxxxxxxxx
in red the data i want push
Tank's for your help
Cyril
This should do it:
<?php
$url = "LAMETRIC_ENDPOINT_URL";
$frames = array(
"frames" => array(
array(
'index' => 0,
'goalData' => array(
'start' => 100,
'current' => 84,
'end' => 75,
'unit' => 'Kg'
)
)
)
);
$curl = curl_init();
$headers = array(
"Accept: application/json",
"X-Access-Token: YOUR_ACCESS_TOKEN",
"Cache-Control: no-cache",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($frames));
$response = curl_exec($curl);
curl_close($curl);
?>
1 person has this question
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstJörg Otto
I am asking to myself, how to do this in PHP? I try to do this with curl but I don't get it.
A lex
This should do it:
<?php
$url = "LAMETRIC_ENDPOINT_URL";
$frames = array(
"frames" => array(
array(
'index' => 0,
'goalData' => array(
'start' => 100,
'current' => 84,
'end' => 75,
'unit' => 'Kg'
)
)
)
);
$curl = curl_init();
$headers = array(
"Accept: application/json",
"X-Access-Token: YOUR_ACCESS_TOKEN",
"Cache-Control: no-cache",
);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, json_encode($frames));
$response = curl_exec($curl);
curl_close($curl);
?>
-
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