Problem with API contacts search using php client library
SOLVE
Hi, I'm afraid this is going to be a n00b question but I can figure out what I'm doing wrong. I would like to pull a list of contacts that have been modified after $date. Seems easy enough, right? Going thru the docs I find the search endpoint in the crm section of the v3 API (https://developers.hubspot.com/docs/api/crm/contacts) and copy the code into my IDE. I make some modifications to hopefully only return contacts modified after 31 January and try running the script. Unfortunately, there seems to be a syntax error in the code from docs page (I get an error when running it from there as well) and my "skills" are lacking when it comes to finding it. My code is:
use HubSpot\Factory; use HubSpot\Client\Crm\Contacts\ApiException;
I've tried working with the braces and brackets, but this syntax is foreign to me and I cannot find the right combination. Any help/point in the right direction is greatly appreciated.
I would spend some time practicing with PHP arrays. This error is telling you you're trying to mix objects with multidimensional arrays. You are also not allowed to use colons as assignment operators in PHP.
In short, replace all of those {} with [] and colons with "=>".
P.S. I have found that the PHP SDK is not intuitive. Instead, I wrote my own cURL wrapped functions to handle data with HubSpot.
I would spend some time practicing with PHP arrays. This error is telling you you're trying to mix objects with multidimensional arrays. You are also not allowed to use colons as assignment operators in PHP.
In short, replace all of those {} with [] and colons with "=>".
P.S. I have found that the PHP SDK is not intuitive. Instead, I wrote my own cURL wrapped functions to handle data with HubSpot.
Problem with API contacts search using php client library
SOLVE
It did help. Thank you. I haven't seriously written any code in a lot of years and even though the example didn't look right to me, I thought it had to be correct because it was in the SDK documentation. Like maybe it was shorthand for creating arrays.
Problem with API contacts search using php client library
SOLVE
That's awesome to hear! Also, I am so used to defining arrays that way I did not even think to mention that it is a shorthand for creating arrays as well.
$var = [];
is the same as
$var = array();
I hope you have more luck than I did with the SDK!
The property I'm looking to search on for contacts is lastmodifieddate. The example you're showing is for deals. I understand that it may work in different areas and/or languages, but I'm trying to use the HubSpot provided PHP SDK (https://developers.hubspot.com/docs/api/overview) so that I can spend more time working with the data instead of writing my own tools.
I copied the example from the search endpoint here https://developers.hubspot.com/docs/api/crm/contacts but that is what is throwing the syntax error. It throws an error when you try to test the example on their own site. The other parts of the PHP SDK that I've used work fine, so I just wrote something using cURL for the search endpoint until a fix is in place.