メディア事業部EC事業部 AGENCY事業部
メディア事業部ブログ
前のページへは、ブラウザの戻るボタンでお戻りください。
arefin

iPhone, Post to Php Server with Parameter

NSURL *url = [NSURL URLWithString: @"http://coumori.test-gbleu.com/f_shop/i_shop.php"];
NSString *body = [NSString stringWithFormat: @"fw=%@",searchString];

NSMutableURLRequest *urlRequest=[NSMutableURLRequest requestWithURL:url];
[url release];

//NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];

[urlRequest setHTTPMethod: @"POST"];
[urlRequest setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]];

//[body release];

NSURLConnection *connectionResponse = [[NSURLConnection alloc] initWithRequest:urlRequest delegate:self];

if (!connectionResponse)
{
NSLog(@”Failed to submit request”);
}
else
{
NSLog(@”——— Request submitted ———”);
NSLog(@”connection: %@ method: %@, encoded body: %@, body: %a”, connectionResponse, [urlRequest HTTPMethod], [urlRequest HTTPBody], body);
NSData *myReturn = [urlRequest HTTPBody];
NSLog(@”myReturn : %@”, myReturn);

NSString *errorDescription = nil;
NSPropertyListFormat format;
NSDictionary *samplePlist = [NSPropertyListSerialization propertyListFromData:myReturn mutabilityOption:NSPropertyListImmutable format:&format errorDescription:&errorDescription];

NSLog(@”samplePlist : %@”, samplePlist);

NSLog(@”New connection retain count: %d”, [connectionResponse retainCount]);
NSMutableData *responseData=[[NSMutableData data] retain];
NSLog(@”response : %@”, responseData);

:!: :!: :!: :!:

WebView with Response data

NSURL *url = [NSURL URLWithString: @"http://coumori.test-gbleu.com/f_shop/i_shop.php"];
NSString *body = [NSString stringWithFormat: @"fw=%@",searchString];

NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]];

[webView loadRequest: request];

カテゴリー:iPad, iPhone , 投稿者名:Arefin Khandoker
PAGE TOP
ページトップへ