小编Car*_*los的帖子

使用transactionReceipt生成JSON对象

过去几天我一直试图测试我的第一个应用程序中的purchse iphone应用程序.不幸的是我无法找到与iTunes服务器通信以验证transactionReceipt的方法.

因为这是我第一次尝试使用这项技术,所以我选择直接从iPhone验证收据,而不是使用服务器支持.但是在尝试使用来自谷歌代码的JSON api创建的JSON onbject发送POST请求之后,itunes总是返回一个奇怪的响应(而不是我等待的"status = 0"字符串).

这是我用来验证收据的代码:

- (void)recordTransaction:(SKPaymentTransaction *)transaction {
    NSString *receiptStr = [[NSString alloc] initWithData:transaction.transactionReceipt encoding:NSUTF8StringEncoding];
    NSDictionary *jsonDictionary = [NSDictionary dictionaryWithObjectsAndKeys:@"algo mas",@"receipt-data",nil];

    NSString *jsonString = [jsonDictionary JSONRepresentation];
    NSLog(@"string to send: %@",jsonString);

    NSLog(@"JSON Created");
    urlData = [[NSMutableData data] retain];

    //NSURL *sandboxStoreURL = [[NSURL alloc] initWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"];

    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://sandbox.itunes.apple.com/verifyReceipt"]];
    [request setHTTPMethod:@"POST"];
    [request setHTTPBody:[jsonString dataUsingEncoding:NSUTF8StringEncoding]];
    NSLog(@"will create connection");
    [[NSURLConnection alloc] initWithRequest:request delegate:self];
}
Run Code Online (Sandbox Code Playgroud)

也许我忘记了请求标题中的内容,但我认为问题出在我用来创建JSON对象的方法中.

在将JSON对象添加到HTTPBody之前,它是如何看起来的:

    string to send: {"receipt-data":"{\n\t\"signature\" = \"AUYMbhY

       ...........

D0gIjEuMCI7Cn0=\";\n\t\"pod\" = \"100\";\n\t\"signing-status\" = \"0\";\n}"} …
Run Code Online (Sandbox Code Playgroud)

json itunesconnect objective-c storekit iphone-sdk-3.0

8
推荐指数
1
解决办法
2万
查看次数

FBConnect facebook.stream.publish与NSDictionary问题

我有这个代码,直到现在才能发送Facebook请求.

NSDictionary *firstDict = [NSDictionary dictionaryWithObjectsAndKeys:
    @"image", @"Type",
    @"http://mysite.com/image.jpg", @"src",
    @"http://mysite.com/page.html", @"href",
    nil];
NSDictionary *secondDict = [NSDictionary dictionaryWithObjectsAndKeys:
    @"image", @"Type",
    @"http://mysite.com/image.jpg", @"src",
    @"http://mysite.com/page.html", @"href",
    nil];
NSArray *mediaArray = [[NSArray alloc] initWithObjects:firstDict, secondDict, nil];

NSArray *keys = [NSArray arrayWithObjects:@"name", @"description", @"href", @"media", nil];
NSArray *objects = [NSArray arrayWithObjects:
    [NSString stringWithString:@"MyTitle"],
    [NSString stringWithString:@"My caption"],
    [NSString stringWithString:@"http://mysite.com/page.html"], mediaArray, nil];

NSDictionary *attachment = [NSDictionary dictionaryWithObjects:objects forKeys:keys];
[[FBRequest requestWithDelegate:self] call:@"facebook.stream.publish" params:attachment];
Run Code Online (Sandbox Code Playgroud)

我拿了这个样本:http://forum.developers.facebook.com/viewtopic.php?pid = 145965

但是每次运行它时,控制台都显示以下内容:

 {
     "api_key" = adc8d70987098sdc;
     "call_id" = 23456767; …
Run Code Online (Sandbox Code Playgroud)

iphone cocoa-touch fbconnect

4
推荐指数
1
解决办法
8315
查看次数