Skip to content
This repository has been archived by the owner on Dec 30, 2020. It is now read-only.

boards->forUser() Not returning secret boards. #244

Closed
zjzeit opened this issue Mar 4, 2017 · 9 comments
Closed

boards->forUser() Not returning secret boards. #244

zjzeit opened this issue Mar 4, 2017 · 9 comments

Comments

@zjzeit
Copy link

zjzeit commented Mar 4, 2017

I have a staging pinterest account (non-business) with 2 public boards, 2 secret boards. On staging, boards->forUser() will successfully grab all 4 boards. On my business Pinterest account, I have 88 public boards and 4 secret boards. Using boards->forUser('userHere',100) with this business account only fetches 88 of the 92 boards. Not sure if the difference in number of boards or difference in type of account (normal vs business) is causing the change in behavior.

@seregazhuk
Copy link
Owner

Hi, @zjzeit
When you are trying to fetch business account boards, are you logged in you business account?
I've just created a secret board and it was returned only if I was logged in this account. For other accounts it stays invisible.

@zjzeit
Copy link
Author

zjzeit commented Mar 4, 2017

I am logged into the business account. To verify: I was able to pin from a business account to a secret board using the board ID (thus proving the credentials work). That is sufficient for what I need (I can hardcode the secret boardID), I'm just not able to fetch the secret board via boards->forUser(). I'm wondering if Pinterest doesn't respond with secret boards when the query returns > 20 (or some number) of results. Thanks for this awesome code!

@seregazhuk
Copy link
Owner

seregazhuk commented Mar 4, 2017

I cannot reproduce it. I've registered a new business account. Created 88 public and 8 private boards.
All of them can be fetched.
My credentials: bimutriche@housat.com: secret
Try it yourself:

$bot = PinterestBot::create();
$bot->auth->login('bimutriche@housat.com', 'secret');

$boards = $bot->boards->forUser('bimutriche');

echo count($boards);  // 96

@zjzeit
Copy link
Author

zjzeit commented Mar 5, 2017

Ah thanks for the demo! I was able to replicate the issue but realized the issue only existed because I modified your getUser function. The issue was certainly on my end.
Within forUser() I changed the below, which caused the problem.

from
return $this->execGetRequest(['username' => $username], UrlBuilder::RESOURCE_GET_BOARDS);
to
return $this->execGetRequest(['username' => $username,'field_set_key'=>'detailed'], UrlBuilder::RESOURCE_GET_BOARDS);

After undoing that change, I was able to get all the secret boards again.
I made the change because I needed more board information from the request (I needed all board image_cover_urls and pin_counts, but wanted to only make 1 query), but this resulted in only grabbing public boards.

If you have a way to grab all of a user's boards (including extra data like the image_cover_url and pin_count), that would be awesome. Sorry to post an issue that was really my own issue [:

@seregazhuk
Copy link
Owner

Oh, I see. I'll research it. Now you can use this

$bot->boards->info('username', 'boardname');

to get board detail information.

@zjzeit
Copy link
Author

zjzeit commented Mar 5, 2017

Gotcha. That would involve iterating through each board as in:

for ($bot->boards->forUser('username') as $board)
{
   $bot->boards->info($board['name']); // note: replace key with whatever key gives the board name
}

Calling info() on each instance would be a lot of URL requests to Pinterest. I was hoping to avoid that many requests, No need to research it on my account! (Unless you are just curious, which I definitely understand). I have accomplished what I need.

@seregazhuk
Copy link
Owner

seregazhuk commented Mar 5, 2017

@zjzeit
Was field_set_key the only change you made?
I've updated the method like you:

    /**
     * Get boards for user by username.
     *
     * @param string $username
     *
     * @return array|bool
     */
    public function forUser($username)
    {
        $options = [
            'username' => $username,
            'field_set_key'=>'detailed',
        ];
        return $this->execGetRequest($options, UrlBuilder::RESOURCE_GET_BOARDS);
    }

And it still returns all the boards. Do you have any ideas with your issue behaviour?

@zjzeit
Copy link
Author

zjzeit commented Mar 7, 2017

Yeah it's weird: because I cannot replicate the issue with a generated business account, I don't know how to diagnose it. field_set_key was the only change I made. It's not an issue anymore as I can still get the data I need.

@seregazhuk
Copy link
Owner

Maybe it was an issue on Pinterest side. Anyway, in the next release, I will add 'field_set_key'=>'detailed' as a default behavior for boards-> forUser() method.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants