我正在使用一个小的python脚本发布到我的Web服务器。现在它成功连接我收到一个错误,说我的值不能为空。当我使用PostMan插件进行chrome时,我没有收到错误,并且收到了成功的返回消息。
这是我在Python中的帖子功能:
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)
以下是我使用PHP(symfony)操作引入变量的方法:
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>
答案 0 :(得分:0)
出现问题是因为我使用的是HTTP而不是HTTPS