Using filters with PHP API Client

Hi everyone.

Unless I’m missing something, there doesn’t appear to be documentation for how to filter results when using the Blog Posts API via the PHP API Client.

I can see options for filtering here, but these are for when using a request URL. When I view the ‘Endpoints’ tab and see the PHP examples for retrieving blog posts, there are only a few paramters that can be used - the state (draft/published, etc) isn’t one of them.

I have looked at the PHP API Client on GitHub - but that gives a few basic examples for retrieving contacts.

Is there more complete documentation somewhere?

Hi Craig,

This is what you want:

 $url = "https://api.hubapi.com/cms/v3/blogs/posts?sort=-updatedAt&&language__not_null&limit=10&offset=1";

 $header = array(
 'Content-Type: application/json',
 'authorization: Bearer ' . $bearer
 );

 $ch = curl_init();
 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
 curl_setopt($ch, CURLOPT_URL, $url);
 curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 $result = curl_exec($ch);

Hi @TDwebdev thanks for the quick response.

I’m using the PHP API Client, though. Up until now I’ve written the cURL requests as you have above, but I’d like to utilise this new API client if possible.

$client = Factory::createWithAccessToken(HUBSPOT_ACCESS_TOKEN);

$apiResponse = $client->cms()->blogs()->blogPosts()->blogPostsApi()->getPage(PARAMS HERE);

But the params available do not include any filtering other than basic timestamp data like updated_at, created_after, etc.

To add to this post - I’m also seeing no way of specifying which blog to use. With the blog tags API using the PHP API Client, there doesn’t seem to be a way to specify which blog to obtain tags from.

Is this not documented anywhere?

Hi,
I’ve the same issue, I’m doing a request using the following code:

$this->client->cms()->blogs()->blogPosts()->blogPostsApi()->getPage(...)

How can I add params to the request in order to do some filtering? For example, I need to do the following request:

https://api.hubapi.com/cms/v3/blogs/posts?contentGroupId=XXXX&state=PUBLISHED

I need to filter the posts using the package GitHub - HubSpot/hubspot-api-php: HubSpot API PHP Client Libraries for V3 version of the API · GitHub