Skip to content

Instantly share code, notes, and snippets.

@tkh44
Created January 30, 2012 15:10
Show Gist options
  • Save tkh44/1704888 to your computer and use it in GitHub Desktop.
Save tkh44/1704888 to your computer and use it in GitHub Desktop.
Working PHP connect to Netsuite.
<?php
extract($_POST);
$url = 'https://forms.netsuite.com/app/site/hosting/scriptlet.nl';
$fields = array(
'firstname' => urlencode($firstname),
'lastname' => urlencode($lastname),
'email' => urlencode($email),
'phone' => urlencode($telephone),
'mobilephone' => urlencode($alttelephone),
'custentity_date_of_birth' => urlencode($dob),
'custentity_gender_free_form' => urlencode($gender),
'address_state' => urlencode($state),
'is_person' => urlencode(T),
'deploy' => urlencode(1),
'compid' => urlencode(1128553),
'h' => urlencode(c648b689db7d6015c7c7),
'globalsubscriptionstatus' => urlencode(1),
'leadsource' => urlencode(194926),
'address_country' => urlencode(US),
'script' => urlencode(8)
);
foreach($fields as $key => $value) { $fields_string .= $key.'='.$value.'&';}
rtrim($fields_string, '&');
$useragent="Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_POST, count($fields));
curl_setopt($ch, CURLOPT_POSTFIELDS,$fields_string);
$result = curl_exec($ch);
curl_close($ch);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment