0

Hi i am make beehive scale with loot function, published under gnu/gpl v3. here is link: https://jbmprojekty-sk.translate.goog/aboutbh.php?_x_tr_sch=http&_x_tr_sl=sk&_x_tr_tl=en&_x_tr_hl=sk&_x_tr_pto=wapp

I have big problem, i need send values from scales, temperature and humidity over url adres like this:

http://jbmprojekty.sk/write.php?userid=testrealdata=off&userdata=11;57;12;50;12;29

I am thy this example: https://www.aeq-web.com/sim800-gprs-http-post-get-request-at-commands/?lang=en and not working error on url adress and postdata.

php code for writing values to json:

<!DOCTYPE html>
<html class="img-no-display"><head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>

<?php
  // Read token from URL
  $link = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
  $res = parse_url($link);
  parse_str($res['query'], $params);
  $dateposted = date("Y-m-d")."T".date("H:i:s");
 

  $a_array = array('time' =>$dateposted, 'values' =>$params['userdata']);

  //open or read json data
  $data_results = file_get_contents("user/".$params['userid'].'/data');  
  $tmp = json_decode($data_results);
  $tmp[] = $a_array ;

  if ( $params['realdata'] == "off" ) {
  // Append
  $json = json_encode($tmp);
  file_put_contents("user/".$params['userid'].'/data', $json); 
  }
  else
  {
  // Realdata
  $myfile = fopen("user/".$params['userid']."/data_online", "w") or die("Unable to open file!");
  fwrite($myfile, json_encode($tmp)."\n"); 
  fclose($myfile); }
?>
</body></html>

Can you please help, i canot solve this problem 4 weeks. thx

Working source code that send values from scale, temparature and humidity senzors over url adress like this: http://jbmprojekty.sk/write.php?userid=testrealdata=off&userdata=11;57;12;50;12;29

froshy
  • 1

0 Answers0