2
제발 도와주세요. 나는 7 디지털 프리미엄 API에 대한 HMAC - SHA1 해시를 생성하려고하지만 올바른 서명을 얻을 수 없습니다. 이 게시물 https://oauth1.wp-api.org/docs/basics/Signing.html을 수행 한 다음 코드를 가지고 :7 디지털 API 유효하지 않은 서명
public function __construct(){
$this->timestamp = time();
$this->_nonce = rand();
$this->consumerKey = 'KEY';
$this->consumerSecret = 'SECRET';
$this->signitureMethod = 'HMAC-SHA1';
}
public function buildSignature()
{
$method = 'GET&';
$url = 'https://api.7digital.com/1.2/oauth/requesttoken';
$params = 'oauth_consumer_key='.$this->consumerKey.'&oauth_nonce='.$this->_nonce.'&oauth_signature_method=HMAC-SHA1&oauth_timestamp='.$this->timestamp.'&oauth_version=1.0';
$baseString = $method.urlencode($url).'&'.urlencode($params);
$key = $this->consumerKey . '&' . $this->consumerSecret;
$signature = hash_hmac('sha1', $baseString, $key);
$string = 'https://api.7digital.com/1.2/oauth/requesttoken?oauth_consumer_key='.$this->consumerKey.'&oauth_nonce='.$this->_nonce.'&oauth_signature_method=HMAC-SHA1&oauth_timestamp='.$this->timestamp.'&oauth_version=1.0&oauth_signature='.$signature;
echo $string;
}
나는 또한 작동하지 않습니다 base64_encode와 서명을 인코딩하는 시도도 그래서 같은 키를 urlencode 시도 참고 :
을 $key = urlencode($this->consumerKey) . '&' . urlencode($this->consumerSecret);
참조 페이지도 사용했습니다.
위의 출력 :
당신의 도움이 많이 주시면 감사하겠습니다 사전에 감사합니다!