Hub spot web hook at contact update need dynamic updated contact list as per user at web hook Url

SOLVE
vkumar
Member

After successfully installing APP through oauth process I want to get updated contact list of that account at webhook  url .

I am using static HAPIkey of developer account from which I installed the app.

How can I make that HAPIkey is dynamic?

 

$url1 = "https://api.hubapi.com/contacts/v1/lists/recently_updated/contacts/recent?hapikey=xxxxxx&count=100";

$headers1 = array(
"Content-Type:application/json"
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
$result2 = curl_exec($ch);
$json2 = json_decode($result2);

0 Upvotes
1 Accepted solution

Accepted Solutions
prosa
Solution
Top Contributor

Hi there, Sure I can help. btw I tried using the url you provided for testing and it gave me an wp error. the table does not exist. 

 

Anyways. your best option to keep track of when user data changes is using the webhooks in the app you installed and updating your local db when you get the data in your API call from hubspot. 

 

to do that your server have to have an endpoint where hubspot can send the request everytime a user gets updated. and you need to track property by property. 

 

if you do it the other way pulling data every X time is slower and your data never will be on sync

If this post helped you resolve your issue, please consider marking it as the solution. Thank you for supporting our HubSpot community.

View solution in original post

6 Replies 6
dennisedson
Community Manager

Hi @vkumar 

I am confused as to what you are doing? 

If you have built the app and have already authorized a portal with OAuth, you should not need the hapikey for this specific call. 

Thanks,

Dennis




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

Hi @dennisedson ,

Thanks for your response..!!

Please follow the steps mentioned below for better understanding of the flow i have followed/applied which will further provide or clear my query as of now  - 

 

1- Firstly, I have successfully installed the application using oAuth integration.

2- Further, I created a webhook URL and also created event at contact's first name field during update time .

3-  Now the thing is , I actually need to save recently updated contact list in my database for any hubspot user but when I use above API code at webhook url page, It is giving me recently updated list for only that user who's API key was used whereas I need the contact list of any hubspot user. 

Can you please suggest a way by which that can be attained ?

 

BRIEF - My requirement is to get the recently updated contact list of any hubspot user at WEB HOOK URL.

0 Upvotes
dennisedson
Community Manager

@vkumar 

Gotchya!  Thanks for clearly providing the additional info 😃

Contact lists access permissions are either set to true or false.  There is no list per HubSpot user.  You will want someone from the portal with read access to lists to authorize your app. 

Hope this helps!

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
vkumar
Member

Hi @dennisedson ,

Thanks for your response..!!

 

Requirement - At contact update event I need JSON data and save in my database at my web hook url (https://www.fivestarhomesconstruction.com/webhook_fetch1.php). 

When I use above URL in webhook setting. This is not getting JSON result .

I am using below code at above URL

<?php

$requestBody = file_get_contents('php://input');
$json = json_decode($requestBody, true);
echo $json[0]['portalId'];
?>

 

I checked with requestbin URL in webhook and this is getting fine json result.

 

Can you please suggest a way by which that can be attained ?

 

0 Upvotes
dennisedson
Community Manager

@prosa ,

Do you have any advice on this?

Thanks,

Dennis




Check out our Community Developer Blog
where we feature our Community driven developer podcast and how to content
0 Upvotes
prosa
Solution
Top Contributor

Hi there, Sure I can help. btw I tried using the url you provided for testing and it gave me an wp error. the table does not exist. 

 

Anyways. your best option to keep track of when user data changes is using the webhooks in the app you installed and updating your local db when you get the data in your API call from hubspot. 

 

to do that your server have to have an endpoint where hubspot can send the request everytime a user gets updated. and you need to track property by property. 

 

if you do it the other way pulling data every X time is slower and your data never will be on sync

If this post helped you resolve your issue, please consider marking it as the solution. Thank you for supporting our HubSpot community.

View solution in original post