2012-07-31 3 views
0

http GET은 브라우저에 의해 제한 될 수 있지만 iPhone을 사용하는 경우에는 무엇이 있습니까? 이런 일을한다면 한계는 무엇입니까?http GET Limit (iPhone)

NSString *urlString = [NSString stringWithFormat:@"http://www.hdsjskdjas.com/urlPop.php?vID=%@&pop=%d&tId=%@",videoId,pushPull,[objectSaver openWithKey:@"userId"]]; 
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:urlString]]; 
NSURLConnection *connect = [[NSURLConnection alloc] initWithRequest:request delegate:self]; 

if(connect) { 
    //success; 
} else { 
    //failure; 
} 

내 서버에 정보를 보내려면이 방법을 사용하면 URL의 문자 수 제한은 무엇입니까?

내가 24,000 문자 내 단절을 통해 보낼 수 있도록하려면

...

이 또 다른 옵션은 무엇을 것 달성 할 수없는 경우?

답변

2

큰 덩어리의 데이터를 보내려면 GET 대신 POST를 사용해야합니다. 여기 그것을 사용하는 방법의 예입니다 :이 경우 본체에

NSArray *keys = [NSArray arrayWithObjects:@"Content-Type", @"Accept", @"Authorization", nil]; 
NSArray *objects = [NSArray arrayWithObjects:@"application/json", @"application/json", mytoken, nil]; 
NSDictionary *headerFieldsDict = [NSDictionary dictionaryWithObjects:objects forKeys:keys]; 
NSData *bodyData = [body dataUsingEncoding: NSUTF8StringEncoding]; 

NSMutableURLRequest *theRequest = [[[NSMutableURLRequest alloc] init] autorelease]; 
[theRequest setURL:[NSURL URLWithString:url]]; 
[theRequest setHTTPMethod:@"POST"]; 
[theRequest setTimeoutInterval:timeout]; 
[theRequest setAllHTTPHeaderFields:headerFieldsDict]; 
[theRequest setHTTPBody:bodyData]; 

NSLog(@"userSendURL URL: %@ \n",url); 

self.conn = [[[NSURLConnection alloc] initWithRequest:theRequest delegate:self] autorelease]; 

간단한는 NSString 객체이다, 그러나 당신이

+0

지금은 참조 할 방법을 NSData 객체에 삽입 할 수있는 일이 될 수 있습니다 내 PHP 코드 데이터? $ _POST [ 'whatGoesHere']; –

+0

이 예제에서는 POST 스트림 내부의 데이터를 처리합니다. 나는 PHP를 사용한 적이 없지만이 링크가 유용 할 수 있습니다. http://stackoverflow.com/questions/3362145/i-cant-read-my-post-http-requests-body-with-php 여전히 키 값을 사용하려면 다음과 같이 NSString * 본문을 설정할 수 있습니다. NString body = [NSString stringWithFormat : @ "vID = % @ & pop = % d & tId = % @", videoId, pushPull, [objectSaver openWithKey : @ "userId" ]]; HTTP POST에 대한 자세한 정보는 wikipedia에서 확인할 수 있습니다. http://en.wikipedia.org/wiki/POST_(HTTP) – melopsitaco