Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Netsuite SuiteQL OAuth在PHP中的实现_Php_Rest_Oauth_Netsuite_Suitetalk - Fatal编程技术网

Netsuite SuiteQL OAuth在PHP中的实现

Netsuite SuiteQL OAuth在PHP中的实现,php,rest,oauth,netsuite,suitetalk,Php,Rest,Oauth,Netsuite,Suitetalk,我正在尝试访问Netsuite的SuiteTalk REST web服务,以便执行SuiteQL查询。我能够在Postman中获得一个基本请求,但是当我尝试从应用程序发送请求时,我得到一个401未经授权的响应,登录审核跟踪告诉我这是由于“InvalidSignature” 我用于生成签名的代码直接来自: 如果有区别的话,我正在使用沙箱帐户,使用123456_SB1作为我的帐户/领域和https://123456-sb1.suitetalk.api.netsuite.com作为我的基本URL 访问

我正在尝试访问Netsuite的SuiteTalk REST web服务,以便执行SuiteQL查询。我能够在Postman中获得一个基本请求,但是当我尝试从应用程序发送请求时,我得到一个401未经授权的响应,登录审核跟踪告诉我这是由于“InvalidSignature”

我用于生成签名的代码直接来自:

如果有区别的话,我正在使用沙箱帐户,使用
123456_SB1
作为我的帐户/领域和
https://123456-sb1.suitetalk.api.netsuite.com
作为我的基本URL

访问RESTWeb服务的身份验证方法与RESTlet不同吗

foreach ($params as $key => $value) {
    $params[$key] = $key . '=' . $value;
}
$url = config('services.netsuite.host') . '/' . $endpoint . '?' . implode('&', $params);
$httpMethod = $method;
$tokenKey = config('services.netsuite.tokenKey');
$tokenSecret = config('services.netsuite.tokenSecret');
$consumerKey = config('services.netsuite.consumerKey');
$consumerSecret = config('services.netsuite.consumerSecret');
$signatureMethod = 'HMAC-SHA256';
$nonce = md5(mt_rand());
$timestamp = time();
$version = '1.0';
$realm = config('services.netsuite.account');

$baseString = oauth_get_sbs($httpMethod, $url, array('oauth_consumer_key' => $consumerKey,
    'oauth_nonce' => $nonce,
    'oauth_signature_method' => $signatureMethod,
    'oauth_timestamp' => $timestamp,
    'oauth_token' => $tokenKey,
    'oauth_version' => $version));

$key = rawurlencode($consumerSecret) . '&' . rawurlencode($tokenSecret);
$signature = base64_encode(hash_hmac('sha256', $baseString, $key, true));