繁体   English   中英

NetSuite-接受webhook POST数据以使用ASP.NET或PHP创建记录

[英]NetSuite - Accept webhook POST data to create record using ASP.NET or PHP

我们在Unbounce.com上有一个潜在客户生成表单,用于捕获潜在客户数据。 他们有一个Webhook,可以通过POST将数据传输到任何可以接受并处理它的URL。 我们希望构建一个页面来接受此数据并在NetSuite中对其进行处理(可能通过SuiteScript API,但不确定)。 http://www.netsuite.com/portal/developers/resources/APIs/Dynamic%20HTML/SuiteScriptAPI/MS_SuiteScriptAPI_WebWorks.1.1.html

从POST获取的变量以下变量将按顺序从表单传递到NetSuite处理页面:

prog
first_name
last_name
email
parents_email
i_am_a_
phone_number
parents_phone_number
comment

尝试抓住的其他页面变量阅读下面的示例代码,看起来我们可以抓取并存储一些其他项目。 如果是这样,最好将它们存储在访问者资料中的CRM中,以备将来参考:

page_id
page_url
variant

要求示例代码由于我们首选的开发环境是ASP.NET,因此您能否提供示例代码来接受来自Webhook的POST数据并在我们的NetSuite帐户中创建新的CRM记录?

从POST获取数据的示例PHP代码可在http://support.unbounce.com/entries/307685-how-does-the-form-webhook-work上找到示例代码

如果这是一个PHP页面,您将以以下方式获取变量:

// This is a sample PHP script that demonstrates accepting a POST from the
// Unbounce form submission webhook, and then sending an email notification.
function stripslashes_deep($value) {
$value = is_array($value) ?
array_map('stripslashes_deep', $value) :
stripslashes($value);

return $value;
}

// First, grab the form data. Some things to note:
// 1. PHP replaces the '.' in 'data.json' with an underscore.
// 2. Your fields names will appear in the JSON data in all lower-case,
// with underscores for spaces.
// 3. We need to handle the case where PHP's 'magic_quotes_gpc' option
// is enabled and automatically escapes quotation marks.
if (get_magic_quotes_gpc()) {
$unescaped_post_data = stripslashes_deep($_POST);
} else {
$unescaped_post_data = $_POST;
}
$form_data = json_decode($unescaped_post_data['data_json']);

// If your form data has an 'Email Address' field, here's how you extract it:
$email_address = $form_data->email_address[0];

// Grab the remaining page data...
$page_id = $_POST['page_id'];
$page_url = $_POST['page_url'];
$variant = $_POST['variant'];

但是我不知道用于将其导入NetSuite的代码。 在从NetSuite审查了SuiteScript API之后,看起来我们应该使用nlobjRequest或nlapiRequestURL,但是我对如何将其与上面的示例PHP页面集成一无所知。

感谢您为NetSuite新手提供的所有帮助。

您将需要在NetSuite中创建一个RESTlet。 您可以在《 NetSuite帮助指南》中找到文档。 RESTlet是NetSuite SuiteScript API的一部分。 它们以JavaScript编写(当然,使用NetSuite提供的API)。

创建RESTlet时,将为您提供一个URL。 您应该将其用于Unbounce网络挂钩。 您的RESTlet应该解析Unbounce.com传递的JSON数据。

暂无
暂无

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

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