Stefano
Stefano

Reputation: 33

Create Pin PDKResponseObject response not consistent with documentation

We are creating a pin in a specific Board by using the method createPinWithImageđź”—onBaord:description:progress:withSuccess:andFailure:

We read in the documentation (here: https://developers.pinterest.com/docs/api/overview/ and here: https://github.com/pinterest/ios-pdk/blob/master/Pod/Classes/PDKClient.h#L417) that this method should return a PDKResponseObject *responseObject with the ID, URL, clickthrough URL and description of the created Pin.

We have been creative enough to try to access the ID of the Pin and its URL using any possible key (@"id", @"identifier", @"url", @"NSUrl") but the values returned are always nil. In fact the PDKResponseObject returns only 2 keys: Board ID and Pin Description. What should we do to access the ID or, at the very least, the URL of the newly created Pin?

Does anybody have the same issue?

Upvotes: 0

Views: 39

Answers (1)

Stefano
Stefano

Reputation: 33

Despite multiple attempts and after having tried to discuss this issue with the Pinterest development Team, this still remains. Testing a solution becomes also extremely difficult considering the new limitation Pinterest has imposed on not approved apps (which include all apps under development by definition).

For now, I only found a way around by calling a new request to get all pins in a specific board and get the first in the resulting array (which is the last posted):

        //Create pin in Pinterest
        [[PDKClient sharedInstance]createPinWithImage:image link:urlToShare 
        onBoard:reference description:message progress:nil 
        withSuccess:^(PDKResponseObject *responseObjectCreation) {

            //Previous block does not return pin id so a new call is required
            [[PDKClient sharedInstance]getBoardPins:reference fields:[NSSet 
            setWithArray:@[@"link"]] withSuccess:^(PDKResponseObject 
            *responseObject) {

                //Get id of last pin
                NSArray *pinIDs = [[NSArray arrayWithArray:[responseObject 
                pins]]valueForKey:@"identifier"];

                NSString *postId = [pinIDs objectAtIndex:0];
            }];
        }];

By the way, the right key for the pin ID is "identifier" and not "id" or "ID" as said in the API documentation. Just found out by trying multiple times and checking the Pinterest Example app in GitHub.

Hope this helps other people who are fighting the same problem.

Upvotes: 0

Related Questions