0

我需要通过发布请求将此 SomeString 发送到服务器。无需使其成为NSData对象并执行NSUTF8StringEncoding SetHttpBody:仅向我询问 NSData 对象。我怎样才能发布这个字符串

SomeString = @"registerRecipt.aspx?udid=962c3486-a8d6-4c32-9ff8-7b255cce4d65&receipt=ewoJInNpZ25hdHVyZSIgPSAiQW1wMnhiVGxYTGg5UmhFUUlCMzNLMHdZdHl3Tnd0WWFVaEdKQzNoUE04Rm8wSys4NE5wWkdWdWRFRndjQ0k3Q2draVluWnljeUlnUFNBaU1TNHdJanNLZlE9PSI7CgkiZW52aXJvbm1lbnQiID0gIlNhbmRib3giOwoJInBvZCIgPSAiMTAwIjsKCSJzaWduaW5nLXN0YXR1cyIgPSAiMCI7Cn0="

NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://someUrl.com/"]];
request.timeoutInterval = 20;
[request setHTTPMethod:@"POST"];
[request setHTTPBody:SomeString];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
4

2 回答 2

2

您可以使用[SomeString dataUsingEncoding:NSUTF8StringEncoding];

于 2011-11-28T13:04:03.317 回答
0
  1. 为了便于开发,使用ASIHTTPRequest
  2. Base64 字符串中的 JSON 无效。
  3. UDID 已弃用,使用从您的 iphone 插入 mac 地址
于 2011-11-28T13:14:03.760 回答