app purchase receipt?

I am trying to verify my IAP receipt with the following code, but it's not working:

- (void)completeTransaction:(SKPaymentTransaction *)transaction {

    NSString* receiptString = [self createEncodedString:transaction.transactionReceipt];
    NSURL *url = [NSURL URLWithString:@"http://my.website.com/"];
    AFHTTPClient *httpClient = [[AFHTTPClient alloc] initWithBaseURL:url];
    NSDictionary *params = [NSDictionary dictionaryWithObjectsAndKeys:
                            receiptString, @"receipt",
                            NO, @"isSandbox",
                            nil];
    NSMutableURLRequest *request = [httpClient requestWithMethod:@"POST" path:@"/verifyReceipt.php" parameters:params];

    AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request];

    [operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) 
        {

            NSLog(@"success: %@", operation.responseString);



        } 
        failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            NSLog(@"error: %@",  operation.responseString);

        }
    ];

    [self recordTransaction:transaction];
    [self provideContent:transaction.payment.productIdentifier];
    [[SKPaymentQueue defaultQueue] finishTransaction:transaction]; 
}
- (NSString*) createEncodedString:(NSData*)data
{
    static char table[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";

    const int size = ((data.length + 2)/3)*4;
    uint8_t output[size];

    const uint8_t* input = (const uint8_t*)[data bytes];
    for (int i = 0; i > 18) & 0x3F];
        output[index + 1] =  table[(value >> 12) & 0x3F];
        output[index + 2] = (i + 1) > 6)  & 0x3F] : '=';
        output[index + 3] = (i + 2) > 0)  & 0x3F] : '=';
    }    

    return  [[NSString alloc] initWithBytes:output length:size encoding:NSASCIIStringEncoding];
}

The PHP script that i am using to verify the data can be found here: http://www.phpriot.com/articles/verifying-app-store-receipts-php-curl

What am i doing wrong?

链接地址: http://www.djcxy.com/p/68084.html

上一篇: FaceBook Connect。 点击登录

下一篇: 应用购买收据?