简体   繁体   English

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

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

We have a lead generation form at Unbounce.com that is capturing lead data. 我们在Unbounce.com上有一个潜在客户生成表单,用于捕获潜在客户数据。 They have a webhook that can transmit the data via POST to any URL that can accept it and process it. 他们有一个Webhook,可以通过POST将数据传输到任何可以接受并处理它的URL。 We would like to build a page that accepts this data and processes it in NetSuite (probably via the SuiteScript API's, but not sure). 我们希望构建一个页面来接受此数据并在NetSuite中对其进行处理(可能通过SuiteScript API,但不确定)。 http://www.netsuite.com/portal/developers/resources/APIs/Dynamic%20HTML/SuiteScriptAPI/MS_SuiteScriptAPI_WebWorks.1.1.html http://www.netsuite.com/portal/developers/resources/APIs/Dynamic%20HTML/SuiteScriptAPI/MS_SuiteScriptAPI_WebWorks.1.1.html

Variables To Get From POST The following variables will be passed from the form in this order to the NetSuite processing page: 从POST获取的变量以下变量将按顺序从表单传递到NetSuite处理页面:

prog
first_name
last_name
email
parents_email
i_am_a_
phone_number
parents_phone_number
comment

Additional Page Variables To Attempt To Grab Reading the example code below it looks like we can grab and store a few additional items. 尝试抓住的其他页面变量阅读下面的示例代码,看起来我们可以抓取并存储一些其他项目。 If so it would be good to store them in the CRM in the visitors profile for future reference: 如果是这样,最好将它们存储在访问者资料中的CRM中,以备将来参考:

page_id
page_url
variant

REQUEST FOR SAMPLE CODE Since our preferred development enviornment is ASP.NET, can you provide sample code that can accept POST data from a webhook and create a new CRM record within our NetSuite account? 要求示例代码由于我们首选的开发环境是ASP.NET,因此您能否提供示例代码来接受来自Webhook的POST数据并在我们的NetSuite帐户中创建新的CRM记录?

SAMPLE PHP CODE TO GET DATA FROM POST Example code can be found at http://support.unbounce.com/entries/307685-how-does-the-form-webhook-work 从POST获取数据的示例PHP代码可在http://support.unbounce.com/entries/307685-how-does-the-form-webhook-work上找到示例代码

If this were a PHP page you would grab the variables in the following fashion: 如果这是一个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'];

However I don't know the code to use to get it into NetSuite. 但是我不知道用于将其导入NetSuite的代码。 After reviewing the SuiteScript API from NetSuite it looks like we should be using nlobjRequest or nlapiRequestURL, but I have zero knowledge on how to integrate this with the sample PHP page above. 在从NetSuite审查了SuiteScript API之后,看起来我们应该使用nlobjRequest或nlapiRequestURL,但是我对如何将其与上面的示例PHP页面集成一无所知。

Thanks for all your help for a NetSuite noob. 感谢您为NetSuite新手提供的所有帮助。

You would need to create a RESTlet in NetSuite. 您将需要在NetSuite中创建一个RESTlet。 You can find the documentation on NetSuite's Help Guide. 您可以在《 NetSuite帮助指南》中找到文档。 RESTlets are part of NetSuite's SuiteScript API. RESTlet是NetSuite SuiteScript API的一部分。 They are written as JavaScript (of course, using the APIs provided by NetSuite). 它们以JavaScript编写(当然,使用NetSuite提供的API)。

When you create a RESTlet, you will be given a URL. 创建RESTlet时,将为您提供一个URL。 Which you should use for your Unbounce web hook. 您应该将其用于Unbounce网络挂钩。 Your RESTlet should parse the JSON data being passed by Unbounce.com. 您的RESTlet应该解析Unbounce.com传递的JSON数据。

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

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