我真的在这个问题上摸不着头脑.我正在使用Pocket API允许用户从我的应用程序存档Pocket文章,但每当我尝试使用以下代码时,我会收到此错误:
错误域= PocketSDK代码= 400"请求无效,请参阅API文档"UserInfo = 0xc17d3b0 {NSLocalizedDescription =无效请求,请参阅API文档}
码:
NSDictionary *arguments = @{@"action": @"archive", @"item_id": articleID}; [[PocketAPI sharedAPI] callAPIMethod:@"send" withHTTPMethod:PocketAPIHTTPMethodPOST arguments:arguments handler:^(PocketAPI *api, NSString *apiMethod, NSDictionary *response, NSError *error) { if (!error) { NSLog(@"Archived article."); } }];
究竟哪一部分不正确?我不是将发送方法发布到API吗?
编辑:我甚至改变它有@"action"
是@"actions"
和提供它上面的NSDictionary,并返回没有错误,但并不影响它的掌上网站上...
编辑2:根据Joseph Chen的回复,我将代码更改为以下内容:
// Create data to pass to the Pocket API (a JSON array of actions) NSError *error; NSArray *actions = @[@{@"action": @"archive", @"item_id": articleID}]; NSData *actionsAsJSONData = [NSJSONSerialization dataWithJSONObject:actions options:kNilOptions error:&error]; NSString *actionsAsJSONString = [[NSString alloc] initWithData:actionsAsJSONData encoding:NSUTF8StringEncoding]; NSDictionary *arguments = @{@"actions": actionsAsJSONString}; [[PocketAPI sharedAPI] callAPIMethod:@"send" withHTTPMethod:PocketAPIHTTPMethodPOST arguments:arguments handler:^(PocketAPI *api, NSString *apiMethod, NSDictionary *response, NSError *error) { if (!error) { NSLog(@"%@", response); } else { NSLog(@"%@", error); } }];
哪个回报:
action_results" = ( 1 ); status = 1;
然而,当我进入网站并登录时,我"存档"的文章仍然盯着我,没有归档.