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 使用esm_msa1_t12_100M_UR50S蛋白质语言模型进行零样本预测时,终端显示出了sequence handled的进度条,但是并不出结果就自动终止回到命令提示行了是怎么回事:
  • ¥15 前置放大电路与功率放大电路相连放大倍数出现问题
  • ¥30 关于<main>标签页面跳转的问题
  • ¥80 部署运行web自动化项目
  • ¥15 腾讯云如何建立同一个项目中物模型之间的联系
  • ¥30 VMware 云桌面水印如何添加
  • ¥15 用ns3仿真出5G核心网网元
  • ¥15 matlab答疑 关于海上风电的爬坡事件检测
  • ¥88 python部署量化回测异常问题
  • ¥15 在现有系统基础上增加功能