First Time setup of API V3

Cainley
Participant

I need help.  I need basic help.  

 

Here is the deal.

 

I am running this code below from PHPStorm with the commposer installed an pointed.

 

I cannot get the local web server to run it,  And I get a 500 error when running it on the PHP/IIS Web server where I have WordPress running.

 

Just running the code in php gets me an error 255.

 

I have loaded thousands of contacts using the URL version of the API.  What requirment am I missing to run the API V3 factory code?

 

<?php
use HubSpot\Factory;
use HubSpot\Client\Crm\Contacts\ApiException;

$client = Factory::createWithApiKey("YOUR_HUBSPOT_API_KEY"); <REPLACED WITH MY KEY.

try {
$apiResponse = $client->crm()->contacts()->basicApi()->getPage(10, null, null, null, false);
var_dump($apiResponse);
} catch (ApiException $e) {
echo "Exception when calling basic_api->get_page: ", $e->getMessage();
}

PHP
5 Replies 5
dennisedson
Community Manager

@MichaelC 👋

Any chance you could help out here?

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
0 Upvotes
Cainley
Participant

Is this how you help the community.  By allowing fake accounts and comments listed as solutions clearly wrong?

 

0 Upvotes
himanshurauthan
Recognized Expert | Platinum Partner

Hello @Cainley,

 

Can you please explain a bit more about what you were trying to do and which API you used for this etc so that I can give you a proper solution for this?

 

Regards,

Digital Marketing & Inbound Expert In Growth Hacking Technology
Cainley
Participant

Sure:

 

See this code taken from V3 API documentation from Hubspot Development:

<?php
use HubSpot\Factory;
use HubSpot\Client\Crm\Contacts\ApiException;

$client = Factory::createWithApiKey("YOUR_HUBSPOT_API_KEY"); <REPLACED WITH MY KEY.

try {
$apiResponse = $client->crm()->contacts()->basicApi()->getPage(10, null, null, null, false);
var_dump($apiResponse);
} catch (ApiException $e) {
echo "Exception when calling basic_api->get_page: ", $e->getMessage();
}

 

 

The code runs on the documentation web site for Hubspot and returns my data.  I am replicating this on my system now.   

 

I am using PHPStorm,  I have installed the package and examples for V3 API and all referances dependents resolve to the proper Factory.php and the Vendors used through composer.  

 

I have compiled the the code in run time in PHPStorm both on the local web server as well as the fully functinoal PHP web server hosted on an IIS server.

 

It would apper that the V3 API does not allow me to connect OR the hosting PHP server is missing some dependent.

 

Thanks

0 Upvotes
Cainley
Participant

You can find the exmple of accessing the 

Contact at this web site:  https://developers.hubspot.com/docs/api/crm/contacts. See Enpoints.

0 Upvotes