2
我在應用程序內購買與iTune的實現代碼連接和我的服務器下載文件。如何在應用程序內購買交易發送包含產品ID和identifierForVendor在JSON到我的服務器
我想通過使用「POST」發送的產品ID和identifierForVendor和transaction.bytes在JSON。 這是顯示層次結構的圖像。
我在谷歌搜索,我發現這部分,但它在的NSString,它通過GET方法
- (BOOL)verifyReceipt:(SKPaymentTransaction *)transaction {
NSString *jsonObjectString = [self encode:(uint8_t *)transaction.transactionReceipt.bytes length:transaction.transactionReceipt.length];
NSString *completeString = [NSString stringWithFormat:@"http://localhost:8888/amm/php_testing_json.php?receipt=%@", jsonObjectString];
NSURL *urlForValidation = [NSURL URLWithString:completeString];
NSMutableURLRequest *validationRequest = [[NSMutableURLRequest alloc] initWithURL:urlForValidation];
[validationRequest setHTTPMethod:@"GET"];
NSData *responseData = [NSURLConnection sendSynchronousRequest:validationRequest returningResponse:nil error:nil];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding: NSUTF8StringEncoding];
NSInteger response = [responseString integerValue];
return (response == 0);
}
- (NSString *)encode:(const uint8_t *)input length:(NSInteger)length {
static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz/=";
NSMutableData *data = [NSMutableData dataWithLength:((length + 2)/3) * 4];
uint8_t *output = (uint8_t *)data.mutableBytes;
for (NSInteger i = 0; i < length; i += 3) {
NSInteger value = 0;
for (NSInteger j = i; j < (i + 3); j++) {
value <<= 8;
if (j < length) {
value |= (0xFF & input[j]);
}
}
NSInteger index = (i/3) * 4;
output[index + 0] = table[(value >> 18) & 0x3F];
output[index + 1] = table[(value >> 12) & 0x3F];
output[index + 2] = (i + 1) < length ? table[(value >> 6) & 0x3F] : '=';
output[index + 3] = (i + 2) < length ? table[(value >> 0) & 0x3F] : '=';
}
return [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
}
任何幫助表示讚賞發送 預先感謝您
謝謝你的幫助,但我怎樣才能把identifireforvendor號,iphone,操作系統和設備,產品ID的名稱? ?我如何使用此值創建JSON?你可以幫我嗎? –
現在,我正在爲應用內購買編寫服務器和客戶端,我可以告訴你(如果我正確理解你的問題),它是*服務器*的作者,誰可以幫助你。對於蘋果公司的收據驗證它足以只發送回執,其餘全部服務器的作者最有可能的定製需求的用途:服務器(本地)收到驗證所以對於,記錄,交易數據庫等 – makaron
(初步驗證了蘋果的驗證發送回執之前)現在,僅僅爲了測試,你可以用虛擬硬編碼數據填充字段(*收據*除外,它必須是真實的。也許productId(部分服務器也可以在本地驗證收據) - 這是你購買的產品的ID並因此得到您的收據)。因此,用假數據發送請求,看看你得到的迴應你期望 – makaron