Logo

创建一个注册页面

按照逐步说明创建模板和落地页,并最终通过 HubSpot API 发布。

概念

创建一个注册页面

按照逐步说明创建模板和落地页,并最终通过 HubSpot API 发布。

1import fetch from 'node-fetch'; 2const fs = require('fs'); 3 4const headerParameters = { 5 Authorization: "Bearer {{ACCESS_TOKEN}}", 6 "Content-Type": "application/json", 7}; 8 9function createSignupTemplate(input) { 10 const endpointUrl = new URL("https://api.hubapi.com/content/api/v2/templates"); 11 12 const bodyParameters = JSON.stringify({ 13 "category_id": 1, 14 "is_available_for_new_content": false, 15 "template_type": 4, 16 "path": "custom/page/examples/signuptemplate.html", 17 "source": input, 18 }); 19 20 const options = { 21 method: "POST", 22 headers: headerParameters, 23 body: bodyParameters, 24 }; 25 26 async function createTemplate() { 27 try { 28 const response = await fetch(endpointUrl, options); 29 printResponse(response); 30 } catch (error) { 31 printError(error); 32 } 33 } 34 35 createTemplate(); 36} 37 38fs.readFile('signup.html', (err, inputD) => { 39 createSignupTemplate(inputD.toString()); 40});
1import fetch from "node-fetch"; 2 3// 定义接口地址 4const endpointUrl = new URL("https://api.hubapi.com/cms/v3/pages/landing-pages"); 5 6// 定义请求头 7const headerParameters = { 8 Authorization: "Bearer {{ACCESS_TOKEN}}", 9 "Content-Type": "application/json", 10}; 11 12// 定义请求体 13const bodyParameters = JSON.stringify({ 14 "name": "signup", 15 "slug": "signup", 16 "templatePath": "custom/page/examples/signuptemplate.html", 17}); 18 19// 设置 API 调用选项 20const options = { 21 method: "POST", 22 headers: headerParameters, 23 body: bodyParameters, 24}; 25 26// 创建异步函数执行 API 调用 27async function createLandingPage() { 28 try { 29 const response = await fetch(endpointUrl, options); 30 printResponse(response); 31 } catch (error) { 32 printError(error); 33 } 34} 35 36// 调用函数执行 API 调用 37createLandingPage();
1console.log("<a target=blank href={{PAGE_URL}}>预览你的页面!</a>");

CMS性能

结论