In the below Pyhton code i am trying to pass some data to my PHP Web service. But i am not getting the data. as the response parameter i get the 'POST Variable not found ' as i done in my PHP file
import httplib,json,urllib
headers = { "charset":"utf-8",
"Accept": "text/plain"}
conn = httplib.HTTPConnection("104.236.91.122")
bulkData = json.dumps({'themo' : 12, 'humidity' : 34}, ensure_ascii = 'False')
postData = urllib.urlencode({'results':bulkData})
conn.request("POST", "/rpi/rpi.php", postData,headers)
response = conn.getresponse()
text = response.read()
print response.status,text
conn.close()
My PHP file
<?php
if (isset($_POST['results']))
{
$data = json_decode($_POST['results']);
foreach($data as $record)
{
foreach($record as $key => $value)
{
echo $key . '->' .$value;
}
}
}
else
{
echo 'POST Variable not found ';
}
?>