【问题标题】:NetSuite - Accept webhook POST data to create record using ASP.NET or PHPNetSuite - 接受 webhook POST 数据以使用 ASP.NET 或 PHP 创建记录
【发布时间】:2013-02-24 13:25:45
【问题描述】:

我们在 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 新手的所有帮助。

【问题讨论】:

    标签: php asp.net api post netsuite


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-26
      • 1970-01-01
      • 2021-08-13
      • 1970-01-01
      • 2019-07-02
      相关资源
      最近更新 更多