PHP Code:
function curl_post($url, array $post NULL, array $options = array()) 

    
$defaults = array( 
        
CURLOPT_POST => 1
        
CURLOPT_HEADER => 0
        
CURLOPT_URL => $url
        
CURLOPT_FRESH_CONNECT => 1
        
CURLOPT_RETURNTRANSFER => 1
        
CURLOPT_FORBID_REUSE => 1
        
CURLOPT_TIMEOUT => 4
        
CURLOPT_POSTFIELDS => http_build_query($post
    ); 

    
$ch curl_init(); 
    
curl_setopt_array($ch, ($options $defaults)); 
    if( ! 
$result curl_exec($ch)) 
    { 
        
trigger_error(curl_error($ch)); 
    } 
    
curl_close($ch); 
    return 
$result


$url 'https://forms.netsuite.com/app/site/hosting/scriptlet.nl';

if(isset(
$_POST['submit']))

    
$payload '{items:[';
    
    for(
$x 0$x <= $fldcount$x++)
    {
        if(!empty(
$_POST['product' $x]))
        {
            
$payload .= "{code:\"" $_POST['product' $x] . ",qtymissing:" $_POST['qtym' $x] . ",qtydamaged:" $_POST['qtyd' $x] . ",note:" $_POST['label' $x] . "}";
            if(
$x != $fldcount && !empty($_POST['product' . ($x 1)]))
            {
                
$payload .= ",";    
            }
        }
    }
    
    
$payload .= "]}";

    
$fields = array(
        
'script'    => 15,
        
'deploy'    => 1,
        
'compid'    => 25476,
        
'h'            => 'ba91648bbcc505325292',
        
'auth'        => $psk,
        
'po'        => $_POST['po'],
        
'lines'        => $payload
    
);

    
$options = array(
        
CURLOPT_RETURNTRANSFER    => true,
        
CURLOPT_SSL_VERIFYPEER    => false,  //Set to false for testing purposes.
        
CURLOPT_SSL_VERIFYHOST    => 2,
        
CURLOPT_CAINFO            => getcwd() . "/cacerts/VeriSignClass3PublicPrimaryCertificationAuthority-G5.crt"
    
);
    
    
$nsResponse curl_post($url$fields$options); 
You might try setting a user agent header to mimic one of the common browsers
Try posting something to that url from a browser. I hadn't looked at it before but on review it looks like you just took an internal suitelet url and changed the host.

Use a different browser or log out of Netsuite for the test.

To use "forms.netsuite.com" you have to make the suitelet not require login and set the audience to everyone.

相关文章: