-1
,HTTP 포스트에서 IOS SDK 나 아이폰 OS SDK의 HTTP 포스트 전화를해야 할 것이다
컬 https://www.googleapis.com/urlshortener/v1/url \ -H '콘텐츠 유형 : 응용 프로그램/JSON'\ -d '{ "longUrl" "http://www.google.com/"} '
어떤 도움이 필요합니까?
,HTTP 포스트에서 IOS SDK 나 아이폰 OS SDK의 HTTP 포스트 전화를해야 할 것이다
컬 https://www.googleapis.com/urlshortener/v1/url \ -H '콘텐츠 유형 : 응용 프로그램/JSON'\ -d '{ "longUrl" "http://www.google.com/"} '
어떤 도움이 필요합니까?
여기와 Google을 통해 답변을 얻을 수 있습니다. 그러나 여기에 코드 샘플이 있습니다. 더 많은 정보가 필요하시면 더 깊은 검색을하십시오.
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:POST_TARGET_URL] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30.0];
[theRequest setHTTPMethod:@"POST"]; // set the method to post
[theRequest addValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@",QUERY_VALUE_BOUNDRY] forHTTPHeaderField: @"Content-Type"];
NSMutableData *queryData = [[NSMutableData alloc] init];
for (NSString *key in [queryDict allKeys]) { // iterate the keys in an NSDictionary to build the post data with key/value pairs
[queryData appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\n\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
[queryData appendData:[[NSString stringWithFormat:@"%@", [queryDict objectForKey:key]] dataUsingEncoding:NSUTF8StringEncoding]];
[queryData appendData:[[NSString stringWithFormat:@"\n--%@\n", QUERY_VALUE_BOUNDRY] dataUsingEncoding:NSUTF8StringEncoding]]; // begin bounds
}
[theRequest setHTTPBody:queryData]; // set the data object to the body of the post request
_URLConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; // open an NSURLConnection with the request that was just constructed.
이 사이트에는이 질문에 대한 답변이 적어도 2309823094832 개 있습니다. 그들 중 누구를 보았 니? – rooftop