我想使用带有iOS SDK的Pocket API编辑在 Pocket 中保存的数据。然而,虽然尝试了制备方法,但反之亦无反应,错误也随之而来。
作为前提
- 可以使用其他 API (saveURL) 添加 URL。
- 注册应用程序的权限是“添加”和“修改”。
有什么建议吗?谢谢。
NSError* error;
NSArray *actions = @[@{ @"action": @"delete", @"item_id": @"456853615" }];
NSData *jsonData = [NSJSONSerialization dataWithJSONObject: actions
options: kNilOptions
error: &error];
NSString *jsonString = [[NSString alloc] initWithData:jsonData encoding: NSUTF8StringEncoding];
// On ios simulator access_token is saved in NSUserDefaults, but on device in keychain.
// see https://github.com/Pocket/Pocket-ObjC-SDK/blob/master/SDK/PocketAPI.m#L718
NSString *accessToken = [[NSUserDefaults standardUserDefaults] objectForKey: @"PocketAPI.token"];
NSDictionary* argumentDictionary = @{@"consumer_key": @"<MY_CONSUMER_KEY>",
@"access_token": accessToken,
@"actions": jsonString};
[[PocketAPI sharedAPI] callAPIMethod: @"v3/send"
withHTTPMethod: PocketAPIHTTPMethodPOST
arguments: argumentDictionary
handler: ^(PocketAPI *api, NSString *apiMethod, NSDictionary *response, NSError *error){
NSLog(@"response %@", [response description]); // response (null)
NSLog(@"error %@", [error localizedDescription]); // response (null)
}];