PHP操作未从Python脚本接收Post变量
我正在使用一个小python脚本发布到我的web服务器。现在,它成功连接,我得到一个错误返回说,我的值不能为空。当我为chrome使用PostMan插件时,我没有收到错误,并且收到了一条成功的返回消息 以下是我在Python中的post函数:PHP操作未从Python脚本接收Post变量,php,python,symfony,post,Php,Python,Symfony,Post,我正在使用一个小python脚本发布到我的web服务器。现在,它成功连接,我得到一个错误返回说,我的值不能为空。当我为chrome使用PostMan插件时,我没有收到错误,并且收到了一条成功的返回消息 以下是我在Python中的post函数: temperature = {"tempF": 20, "tempC": 70} def post(): threading.Timer(1800.0, post).start() temperature = read_temp()
temperature = {"tempF": 20, "tempC": 70}
def post():
threading.Timer(1800.0, post).start()
temperature = read_temp()
data = temperature
data['room'] = 'Server Room'
print(data)
url = 'http://url.to.server'
query = data
res = requests.post(url, data=query)
print(res.text)
下面是我如何通过PHPsymfony动作引入变量:
public function updateTemperatureAction(Request $request)
{
$tempF = $request->request->get('tempF');
$tempC = $request->request->get('tempC');
$room = $request->request->get('room');
if(empty($tempF)) throw new \Exception("temperature F is empty");
if(empty($tempC)) throw new \Exception("temperature C is empty");
if(empty($room)) throw new \Exception("Room is empty");
$temperature = new Temperature();
$temperature->setTemperatureF($tempF);
$temperature->setTemperatureC($tempC);
$temperature->setRoom($room);
$em = $this->getDoctrine()->getManager();
$em->persist($temperature);
$em->flush();
return new Response($room);
}
这是我的错误:
<h1>Oops! Something went wrong.</h1>
<p>
The server returned a "<strong>500 Internal Server Error</strong>" error. Please contact the website administrator to address this issue.
</p>
<p>
<small>
temperature F is empty
</small>
</p>
<div class="row" id="footer">
<div class="col-md-12">
© Shawmut Printing 2014 <span id="epms_query_time"></span> <span id="data_set_last_updated"></span>
</div>
</div>
</div>
</div>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="/js/initialize.js"></script>
<script src="/js/interface.js"></script>
</body>
</html>
出现问题是因为我使用的是HTTP而不是HTTPS请修复Python代码中的缩进。