Pocket API: how to change data using callAPIMethod?

I would like to edit the data stored in Pocket using the Pocket API with the iOS SDK . However, despite the fact that the preparation method has been tested, no reaction and error occurs, on the contrary.

As a premise

  • URLs can be added using another API (saveURL).
  • Permissions of the registered application: Add and Modify.

Is there any advice? Thanks.

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) }]; 
+1
source share
2 answers

Drop the API version, user_key and access_token. They are added to the SDK.

 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]; NSDictionary* argumentDictionary = @{@"actions":jsonString}; [[PocketAPI sharedAPI] callAPIMethod:@"send" withHTTPMethod:PocketAPIHTTPMethodPOST arguments:argumentDictionary handler:^(PocketAPI *api, NSString *apiMethod, NSDictionary *response, NSError *error){ NSLog(@"response %@", [response description]); NSLog(@"error %@", [error localizedDescription]); }]; 
+2
source

May use NSDictionary for the argument argument.

 NSDictionary *argumentDictionary = @{@"actions" : @[@{@"action" : @"delete", @"item_id" : @"456853615"}]}; [[PocketAPI sharedAPI] callAPIMethod:@"send" withHTTPMethod:PocketAPIHTTPMethodPOST arguments:argumentDictionary handler:^(PocketAPI *api, NSString *apiMethod, NSDictionary *response, NSError *error){ NSLog(@"response %@", [response description]); NSLog(@"error %@", [error localizedDescription]); }]; 
0
source

All Articles