2

如何使用方法将转换收据与产品标识符一起发送到我的服务器HTTP POST?我是否必须使用 base64 对产品标识符进行编码?

我收到了这样的回复:

{"message" : "21002: java.lang.IllegalArgumentException: propertyListFromString 解析了一个对象,但字符串中还有更多文本。plist 应该只包含一个顶级对象。行号:1,列:2478。", “错误”:1}

即使在我使用 base64 编码对转换收据进行编码之后......

这就是我正在做的事情:

NSString *bodyString = [NSString stringWithFormat:@"product_id=%@&receipt_data=%@",self.currentProductIdentifer,
[self.productReceiptData base64Encoding]];
NSData *bodyData = [bodyString dataUsingEncoding:NSUTF8StringEncoding
  allowLossyConversion:YES];
NSAssert(bodyData!=nil,@"HTTP Body is empty !");

//posting the data to server 
NSMutableURLRequest *theRequest=[NSMutableURLRequest requestWithURL:
  [NSURL URLWithString:inUrlString]
  cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:inData];  //inData is http body(bodyData) created above 
 // create the connection with the request // and start loading the data 
NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:theRequest delegate:self]; 
4

0 回答 0