duanluo5096 2015-12-26 21:51
浏览 733
已采纳

使用Tasker / HTTP Get / Post Raspberry Pi设置PHP变量

So I have this code

<?php
if (isset($_POST['submit_var']))
  {
  $formvalue = $_POST['input_value'];
  exec('sudo python LCD_Log_Write.py ' .$formvalue);
  }
?>

<form action="?submit =true" method="POST">
<input type="text" name="input_value">
<input type="submit" name="submit_var">

which is a text box and a submit button, when the button is pressed the text in the text box shows up on an LCD connected to my Raspberry Pi. My question is how do I automate filling in this text box and clicking this button with Tasker? If you're not familiar with Tasker it can use HHTP gets, posts and Heads so if you know how to do it with that you would also be a huge help to me! Thank you!

  • 写回答

1条回答 默认 最新

  • doutiaosu2310 2015-12-27 12:32
    关注

    You could achieve what you need by using Web interface and automating input / clicking, but that would be very inefficient. Best approach is, indeed, using http post.

    Assuming that the code is run when IP 1.2.3.4 is used, you'd create a http post task and you fill it in like that:

    server:port 1.2.3.4

    path /index.php (if that's the file you're using)

    data / file input_value=%txt_var

    submit_var=true

    content-type x-www-form-urlencoded

    If it still doesn't work, leave content-type empty.

    And that should do. Please note the new line in data / file field. Also, the %txt_var is a tasker variable to be filled in prior to sending the http post request

    Since you'd have it done this way you could alter your php code, leaving only first 7 lines (as the rest would not be needed) or go even further and leave only line 4 and 5

    Alternatively, if the if is required, change it to check whether input_value is set and not empty

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器