Please can you help me. I am trying to generate a HMAC-SHA1 hash for 7 Digital's Premium API however I cannot get the correct signiture. I have followed this post https://oauth1.wp-api.org/docs/basics/Signing.html and have got the following code :
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;
}
Please note I have also tried to encode the signature with base64_encode doesn't work and also have tried to urlencode the key like so :
$key = urlencode($this->consumerKey) . '&' . urlencode($this->consumerSecret);
I have used there reference page as well.
The above outputs :
Your help would be much appreciated thank you in advance!!