更新时间:2023-02-24 15:29:14
试试这个,而不是使用密钥发布JSON字符串,您需要将其作为数据发布到您的脚本中以便读入。目前在您的脚本中,您甚至不使用$ handle ...
Try this, instead of posting the JSON string with a key, you need to post it as Data to your script to be read in. Currently in your script you aren't even using $handle for anything...
NSURL *link = [NSURL URLWithString:[phpUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:link];
[request appendPostData:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
[request setTimeOutSeconds:120];
[request setDelegate:self];
和你的PHP代码..
And your php code..
$handle = fopen('php://input','r');
$jsonInput = fgets($handle);
$decoded = json_decode($jsonInput,true);
print_r($decoded);