何かを PHP サーバーに投稿しようとすると、次のメッセージが表示されます。コードがサーバーに接続しているように見えますが、データが返されず、投稿データが通過していません。私が作成したJavaアプリで動作したので、私のPHPに問題がないことを保証できます. あなたが私を助けることができるか、私を助けるためにさらにコードが必要な場合は、それを求めてください. ありがとう。
NSURLConnection 用に変数を準備するコードは次のとおりです。
NSString *phash = [NSString stringWithFormat:@"%d",phashnum];
        [phash stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
name = _nameField.text;
        [name stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
        email = _emailField.text;
        [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
これが私の NSURLConnection のコードです:
NSString *urlPath = [NSString stringWithFormat:@"http://54.221.224.251"];
    NSURL *url = [NSURL URLWithString:urlPath];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
    NSString *stringdata = [NSString stringWithFormat:@"name=%@&email=%@&phash=%@",name,email,phash];
    NSOperationQueue *queue= [[NSOperationQueue alloc]init];
    NSString *postData = [[NSString alloc] initWithString:stringdata];
    [request setValue:@"application/x-www-form-urlencoded; charset=utf-8" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPMethod:@"POST"];
    [request setHTTPBody:[postData dataUsingEncoding:NSUTF8StringEncoding]];
    [NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError) {
        if ([data length] > 0 && connectionError==nil){
            NSLog(@"Connection Success. Data Returned");
            NSLog(@"Data = %@",data);
            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
            int code = [httpResponse statusCode];
            NSString *coder = [NSString stringWithFormat:@"%d",code];
            NSLog(@"%@",coder);
        }
        else if([data length] == 0 && connectionError == nil){
            NSLog(@"Connection Success. No Data returned.");
            NSLog(@"Connection Success. Data Returned");
            NSLog(@"Data = %@",data);
            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
            int code = [httpResponse statusCode];
            NSString *coder = [NSString stringWithFormat:@"%d",code];
            NSLog(@"%@",coder);
        }
        else if(connectionError != nil && connectionError.code == NSURLErrorTimedOut){
            NSLog(@"Connection Failed. Timed Out");
            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
            int code = [httpResponse statusCode];
            NSString *coder = [NSString stringWithFormat:@"%d",code];
            NSLog(@"%@",coder);
        }
        else if(connectionError != nil)
        {
            NSLog(@"%@",connectionError);
            NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
            int code = [httpResponse statusCode];
            NSString *coder = [NSString stringWithFormat:@"%d",code];
            NSLog(@"%@",coder);
        }
    }];
前もって感謝します。