使用GET方法的phpouth1
我需要使用Get方法在php中创建Oauth1请求到Netsuite系统。 我不明白怎么了。我总是收到403登录信息而不是尝试。 我的参数是type和customerId 我的代码:使用GET方法的phpouth1,php,netsuite,Php,Netsuite,我需要使用Get方法在php中创建Oauth1请求到Netsuite系统。 我不明白怎么了。我总是收到403登录信息而不是尝试。 我的参数是type和customerId 我的代码: $oauth_nonce = md5(mt_rand()); $oauth_timestamp = time(); $oauth_signature_method = 'HMAC-SHA1'; $oauth_version = "1.0";
$oauth_nonce = md5(mt_rand());
$oauth_timestamp = time();
$oauth_signature_method = 'HMAC-SHA1';
$oauth_version = "1.0";
$base_string =
"GET&" . urlencode($url) . "&" .
urlencode(
"deploy=" . "1"
."&customerId=" . $customerID
."&type=" . $type
. "&oauth_consumer_key=" . $consumerKey
. "&oauth_nonce=" . $oauth_nonce
. "&oauth_signature_method=" . $oauth_signature_method
. "&oauth_timestamp=" . $oauth_timestamp
. "&oauth_token=" . $token
. "&oauth_version=" . $oauth_version
. "&realm=" . $realm
. "&script=" . $script
);
$sig_string = urlencode($consumerSecret) . '&' . urlencode($tokenSecret);
$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($consumerKey) . '", '
. 'oauth_token="' . rawurlencode($token) . '", '
. 'oauth_timestamp="' . rawurlencode($oauth_timestamp) . '", '
. 'realm="' . rawurlencode($realm) .'"';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '?&script=' . $script . '&deploy=' . "1" . '&realm=' . $realm. "&customerId=" . $customerID."&type=" . $type);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: ' . $auth_header,
'Content-Type: application/json'
]);
$Acode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$Aresult = json_decode(curl_exec($ch));
curl_close($ch);