Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation need updating? #39

Closed
spingary opened this issue Mar 5, 2016 · 2 comments
Closed

Documentation need updating? #39

spingary opened this issue Mar 5, 2016 · 2 comments

Comments

@spingary
Copy link

spingary commented Mar 5, 2016

Hi,

Now that the response is implementing PSR-7 ResponseInterface, does the README need to be updated? Or am I retrieving the results incorrectly?

This seems to be the only way to access the data:

        $response = $hubspot->blogs()->all();
        $blogs = $response->getData();
        foreach ($blogs->objects as $blog) {
            echo($blog->name);
        }

Thank you,
Gary Wong

@ryanwinchester
Copy link
Collaborator

This is the raw response from hubspot:

So you should be able to do either of these ways:

$response = $hubspot->blogs()->all();

// PSR-7, something like:
$contents = $response->getBody()->getContents();
$blogs = $contents->objects;
foreach ($blogs as $blog) {
    echo($blog->name);
}

// That's annoying, so I added some convenience:

// Method to get data from response
$data = $response->getData();
foreach ($data->objects as $blog) {
    echo($blog->name);
}

// Property accessor
foreach ($response->objects as $blog) {
    echo($blog->name);
}
// Array access
foreach ($response['objects'] as $blog) {
    echo($blog->name);
}

@spingary
Copy link
Author

spingary commented Mar 6, 2016

I see - that makes sense. I was just a bit confused by the examples in README (I believe that's pre-PSR7).

Thank you,
Gary

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

No branches or pull requests

3 participants
@ryanwinchester @spingary and others