I have a base64 string (for an in app iOS purchase) and trying to send it to my PHP server so it can validate with apple.
Problem is the string sent is not the string recieved. All the "+" marks inside my string are removed. How can I preserve my string just as it is in the client so my PHP server gets it raw.
Here is my client code
NSDictionary* post = @{@"receipt":[receipt base64EncodedStringWithOptions:0]};
//combines my post with an endpoint inside _post
for (NSString* k in _post)
{
NSLog(@"%@ & %@",k,_post[k]);
postDataStr = [NSString stringWithFormat:@"%@&%@=%@", postDataStr,k,_post[k]];
}
_req = [NSMutableURLRequest requestWithURL:_url cachePolicy:0 timeoutInterval:15.0f];
[_req setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[_req setHTTPMethod:@"POST"];
[_req setHTTPBody:[postDataStr dataUsingEncoding:NSUTF8StringEncoding]];
_data = [NSMutableData data];
[NSURLConnection connectionWithRequest:_req delegate:self];
And on my server its this
$appleReturnedReceipt = $this->getReceiptData($_REQUEST['receipt'], $_REQUEST['sandbox']);
When I trace out the string before and after the server touches it, all the "+" symbols are missing.
Any and all advice appreciated!
UPDATE
Thanks to the kind answer below doing this fixed the issue:
NSString* newPost = [(NSString*)_post[k] stringByReplacingOccurrencesOfString:@"+" withString:@"%2B"];