Ziel-C-> JSON-> PHP-Array

Ich habe in den letzten Tagen damit zu kämpfen. Ich versuche, ein Array in PHP zu posten. Ich kann es erfolgreich senden, aber es wird nicht mit einer Post-Variablen aufgenommen (ich versuche, den Variablenschlüssel "json" zu verwenden ... Mit diesem Code erhalte ich das Array in PHP:

Ziel c

NSError *error;
NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects: @"one", @"two", @"three", nil] forKeys: [NSArray arrayWithObjects: @"a", @"b", @"c", nil]];
NSArray *jsonArray = [NSArray arrayWithObject:jsonDictionary];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:jsonArray options:NSUTF8StringEncoding error:&error];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"somewebservicelocation/arrayTest.php?json="]];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setHTTPMethod:@"POST"];
[request setHTTPBody:jsonData];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *response = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(@"response: %@",response);

PHP

$handle = fopen('php://input','r');
    $array = fgets($handle);
    echo $array;
    if(isset($array))
    {
        echo "success";
    }
    else
    {
        echo "failure";
    }

Wenn ich dieses PHP mit _POST benutze, bekomme ich keine Liebe:

$rawJsonData = $_POST['json'];
$array = json_decode(stripslashes($rawJsonData),true);
echo $array;
if(isset($array))
{
    echo "success";
}
else
{
    echo "failure";
}

... Ich bin schon seit einigen Tagen dabei - alles über Stack Overflow hinweg, und ich muss verstehen, dass ich die Variablen und Daten in den Hauptteil der Anforderung aufnehmen muss, aber ich kann es einfach nicht zum Laufen bringen. Was mache ich falsch? Wie gehst du das anders an? Rette mich vor diesen Kopfschmerzen ...

Antworten auf die Frage(2)

Ihre Antwort auf die Frage