Oracle APEX中使用OAuth进行API Hubspot集成的解决方案示例代码
https://app.hubspot.com/oauth/authorize?client_id=xxxx&redirect_uri=https://localhost&scope=contacts%20content
其中,client_id是您的应用程序的ID,redirect_uri是授权确认后的重定向URI,scope是您想要授权的作用域。
CREATE TABLE hubspot_tokens ( access_token VARCHAR2(200), refresh_token VARCHAR2(200), expires_in NUMBER, fetched_time TIMESTAMP(6) );
INSERT INTO hubspot_tokens VALUES ('xxx', 'yyy', 3600, SYSTIMESTAMP);
DECLARE l_http_request UTL_HTTP.REQ; l_http_response UTL_HTTP.RESP; l_url VARCHAR2(1000) := 'https://api.hubapi.com/contacts/v1/lists/all/contacts/all?hapikey=xxxxx'; --这里的hapikey是Hubspot的API密钥,您需要在Hubspot中创建应用程序并生成一个密钥。 l_clob CLOB; BEGIN l_http_request := UTL_HTTP.BEGIN_REQUEST(l_url, 'GET'); l_http_response := UTL_HTTP.GET_RESPONSE(l_http_request); DBMS_LOB.CREATETEMPORARY(l_clob, TRUE); BEGIN LOOP UTL_HTTP.READ_TEXT(l_http_response, l_buffer); DBMS_LOB.WRITEAPPEND(l_clob, LENGTH(l_buffer), l_buffer); END LOOP; EXCEPTION WHEN UTL_HTTP.END_OF_BODY THEN UTL_HTTP.END_RESPONSE(l_http_response); END;
--从C
上一篇:api缓存网关