I have tried this code(Python side)...
import requests
import json
keys = {"name": "John"}
headers = {'Content-type': 'application/x-www-form-urlencoded', 'Accept': 'text/plain'}
r = requests.post("http://localhost/Python_/test.php", data = keys, headers = headers)
print r.url
print r.status_code
On php side, I am trying to get the name..
print_r($_POST['keys']);
And I am getting this error..
Notice: Undefined index: keys in C:\xampp\htdocs\Python_\test.php on line 8
I tried it on REST client, the code shows the name on REST client but on localhost it got this error.
Your post data will be the keys dictionary.
Your php code should be print_r($_POST['name']);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With