的Python
params = urllib.parse.urlencode({'spam': '1', 'eggs': '2', 'bacon': '3'})
binary_data = params.encode('utf-8')
reg = urllib.request.Request("http://www.abc.com/abc/smart/ap/request/",binary_data)
reg.add_header('Content-Type','application/x-www-form-urlencoded')
f = urllib.request.urlopen(reg)
print(f.read())
PHP
if($_SERVER['REQUEST_METHOD'] == 'POST') {
//parse_str($_SERVER['QUERY_STRING']);
var_dump($_SERVER['QUERY_STRING']);
}
当我尝试打印binary_data时,它确实显示了参数,但是当它到达PHP时,我什么也看不到。
有什么想法吗?
编辑**
我做了更多测试,如果我做了
urllib.request.Request("http://www.abc.com/abc/smart/ap/request/?item='test'",binary_data)
the parameter, item , does get sent to php.