简体   繁体   English

通过 API 将 HubSpot 连接到 SQL Server

[英]Connecting HubSpot to SQL Server over API

Pretty stumped at this point, hopefully someone has been able to figure out this problem before.在这一点上很难过,希望有人以前能够解决这个问题。 I'm trying to create a process that will synchronize my user data from HubSpot and SQL Server (collected through my web app).我正在尝试创建一个进程,该进程将从 HubSpot 和 SQL Server(通过我的 Web 应用程序收集)同步我的用户数据。 This would involve me being able to write into HubSpot from SQL Server or vice versa.这将使我能够从 SQL Server 写入 HubSpot,反之亦然。 In order to do that I need to use their API and I'm having issues connecting to the API itself.为了做到这一点,我需要使用他们的 API,但我在连接到 API 本身时遇到了问题。

I was able to get the connection working with the Google OAuth 2.0 Playground and extract the customer data (so I know they work), but I want to create an equivalent connection R. From the research I've done so far, here's what I think may be the best options:我能够使用 Google OAuth 2.0 Playground 建立连接并提取客户数据(所以我知道它们可以工作),但我想创建一个等效的连接 R。根据我到目前为止所做的研究,这就是我认为可能是最好的选择:

  1. Externally: I found a company called Zapier that apparently can do this if I pay for their services, I have never used them外部:我找到了一家名为 Zapier 的公司,如果我为他们的服务付费,显然可以做到这一点,但我从未使用过它们

  2. Inhouse: Using ROAuth or httr packages, but I couldn't authenticate successfully.内部:使用 ROAuth 或 httr 包,但我无法成功验证。 I've tried:我试过了:

     reqURL<- 'https://api.hubapi.com/contacts/v1/lists/all/contacts/all' accessURL<- "Couldn't figure out?" authURL<- 'https://app.hubspot.com/oauth/authorize?client_id=[my client id]&scope=contacts%20automation&redirect_uri=https://[mywebsite]' cKey<- 'my hubspot app client id' cSecret<- 'my hubspot app client secret' credentials<- OAuthFactory(consumerKey=cKey, consumerSecret=cSecret, requestURL=reqURL, accessURL=accessURL, authURL=authURL)

Also tried:还试过:

curl('https://api.hubapi.com/contacts/v1/lists/all/contacts/all/hapikey=[my hapi key]/get')

Helpful Links:有用的网址:

Fields:领域:

I also have a Hapi key and App ID, but not sure if they're required我也有 Hapi 密钥和 App ID,但不确定是否需要它们

Really appreciate the help!真的很感谢帮助!

Cheers干杯

After some digging, I was able to connect using the HAPI Key, rather than doing OAuth.经过一番挖掘,我能够使用 HAPI 密钥进行连接,而不是使用 OAuth。 It's actually pretty simple:其实很简单:

library(httr)
library(jsonlite)  

hs_data<- GET(paste("https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=",{yourapikey})
hs_data<- content(hs_data, as='text')
hs_data<- fromJSON(hs_data)
hs_data <- hs_data$contacts$properties

Some things that were messing me up previously:之前让我感到困惑的一些事情:

  • Make sure to use your personal HAPI key, not the account (if you're admin) HAPI key确保使用您的个人 HAPI 密钥,而不是帐户(如果您是管理员)HAPI 密钥
  • Make sure only Contacts scope is checked in your app, it doesn't work with more than 1 scope clicked.确保在您的应用中只选中了联系人范围,它不适用于单击超过 1 个范围。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM