1

I have a simple t1.php file which has:

<?php
var_dump($_POST);
?>

and a simple python file which has:

import requests
print requests.post("http://localhost/tempo/t1.php", data={"a":{"b": "c", "d": "e"}}).text

and when I run the python file I get:

array(1) {
  ["a"]=>
  string(1) "d"
}

The question is, where are other parameters and values?

Bardia Zamanian
  • 113
  • 1
  • 6
  • Possible duplicate of [Post JSON using Python Requests](http://stackoverflow.com/questions/9733638/post-json-using-python-requests) – Mikhail M. Feb 19 '17 at 04:32
  • I am not getting 400, and also when I do json= instead of data=, the output would be nothing and even worse – Bardia Zamanian Feb 19 '17 at 04:36
  • you can try first `json_encode($_POST)` than see what will be output – gaurav Feb 19 '17 at 07:29
  • yeah actually I realized that data= encodes the data into parameters format in the body, but with json= it will put the whole thing into the body of the post message which is the true way of doing that, but it is not accessible with $_POST[] and you have to do file_get_contents('php://input') to get your json data. – Bardia Zamanian Feb 20 '17 at 08:27

0 Answers0