POST request from Python to PHP

Posted by RainbowHat on Stack Overflow See other posts from Stack Overflow or by RainbowHat
Published on 2013-10-20T09:52:29Z Indexed on 2013/10/20 9:53 UTC
Read the original article Hit count: 237

Filed under:
|
|
|
|

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']);
}  

When i try print binary_data , it does show the parameter but by the time it reaches the PHP , i see nothing.

Any idea?

© Stack Overflow or respective owner

Related posts about php

Related posts about python