Oauth implementation in netsuite using php -


i have tried access netsuite account id, username , password using php toolkit. , can customer details using above credentials. have access token. tried access netsuite using access token. need php code access netsuite using token , want customer details.

thanks in advance

here code wrote php -> ns integration using restlets , oauth:

define("netsuite_url", 'https://rest.netsuite.com/app/site/hosting/restlet.nl'); define("netsuite_script_id", 'xxxxxx'); define("netsuite_deploy_id", 'xxxxxx'); define("netsuite_account", 'xxxxxx'); define("netsuite_consumer_key", 'xxxxxx'); define("netsuite_consumer_secret", 'xxxxxx'); define("netsuite_token_id", 'xxxxxx'); define("netsuite_token_secret", 'xxxxxx');  function sendordertons($details) {     $data_string = json_encode($details);      $oauth_nonce = md5(mt_rand());     $oauth_timestamp = time();     $oauth_signature_method = 'hmac-sha1';     $oauth_version = "1.0";      $base_string =         "post&" . urlencode(netsuite_url) . "&" .         urlencode(             "deploy=" . netsuite_deploy_id           . "&oauth_consumer_key=" . netsuite_consumer_key           . "&oauth_nonce=" . $oauth_nonce           . "&oauth_signature_method=" . $oauth_signature_method           . "&oauth_timestamp=" . $oauth_timestamp           . "&oauth_token=" . netsuite_token_id           . "&oauth_version=" . $oauth_version           . "&realm=" . netsuite_account           . "&script=" . netsuite_script_id         );     $sig_string = urlencode(netsuite_consumer_secret) . '&' . urlencode(netsuite_token_secret);     $signature = base64_encode(hash_hmac("sha1", $base_string, $sig_string, true));      $auth_header = "oauth "         . 'oauth_signature="' . rawurlencode($signature) . '", '         . 'oauth_version="' . rawurlencode($oauth_version) . '", '         . 'oauth_nonce="' . rawurlencode($oauth_nonce) . '", '         . 'oauth_signature_method="' . rawurlencode($oauth_signature_method) . '", '         . 'oauth_consumer_key="' . rawurlencode(netsuite_consumer_key) . '", '         . 'oauth_token="' . rawurlencode(netsuite_token_id) . '", '           . 'oauth_timestamp="' . rawurlencode($oauth_timestamp) . '", '         . 'realm="' . rawurlencode(netsuite_account) .'"';      $ch = curl_init();     curl_setopt($ch, curlopt_url, netsuite_url . '?&script=' . netsuite_script_id . '&deploy=' . netsuite_deploy_id . '&realm=' . netsuite_account);     curl_setopt($ch, curlopt_post, "post");     curl_setopt($ch, curlopt_postfields, $data_string);     curl_setopt($ch, curlopt_returntransfer, true);     curl_setopt($ch, curlopt_httpheader, [         'authorization: ' . $auth_header,         'content-type: application/json',         'content-length: ' . strlen($data_string)     ]);      curl_exec($ch);     curl_close($ch); } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -