iOS アプリ/Web サービスを構築しています。iOS アプリは、次のようにデータを php scrip に送信します。
NSError* error = nil;
NSURLResponse *res ponse = nil;
NSArray * keys = [NSArray arrayWithObjects:@"addr", @"date", @"o_cond", nil];
NSArray * values = [NSArray arrayWithObjects:addr, date, o_cond, nil];
NSDictionary * info = [NSDictionary dictionaryWithObjects:values forKeys:keys];
NSData* jsonData = [NSJSONSerialization dataWithJSONObject:info options:NSJSONWritingPrettyPrinted error:&error];
NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://myaddr.com/sendEmail.php"]];
[req setHTTPMethod:@"POST"];
[req setHTTPBody:jsonData];
[NSURLConnection sendSynchronousRequest:req returningResponse:&response error:&error];
そしてphpはデータを受け取りました:
<?php
// Get all the posted vars
$jsonInput = file_get_contents('php://input');
$decoded = json_decode($jsonInput, true);
$body = "Inspection Results for " . $decoded->{'addr'} . "\n\n";
$body = $body . "Inspection date and time: " . $decoded->{'date'} . "\n\n";
$body = $body . "Overall condition of asset: " . $decoded->{'o_cond'} . "\n\n"; ?>
しかし、何らかの理由で、php 側でデータを受け取ることができません。ここで何がうまくいかないのか誰にもわかりますか?
ありがとう