SecretId
and a SecretKey
. If you do not have the security credentials yet, you can apply for them at Tencent Cloud's official website; otherwise, you cannot call TencentCloud API.SignatureMethod
parameter. If the parameter value is HmacSHA256
, SHA256 will be used for signature calculation; if this parameter is not specified or its value is not HmacSHA256
, SHA1 will be used.SecretId
and SecretKey
. SecretId
is used to identify the API requester, while SecretKey
is a key used for signature string encryption and authentication by the server. Please keep your SecretKey
private and do not disclose it to others.SecretId/SecretKey
. Each account can have up to two SecretId/SecretKey
pairs.SecretId
and SecretKey
, a signature string can be generated as described below:SecretId
and SecretKey
are:AKIDPcY*****CVYLn3zT
pPgfLip*****aU7UbQyFFx
SecretId
and SecretKey
. SendMessage
API to send a message, the request parameters may be as follows:Parameter Name | Description | Value |
Action | Method name | SendMessage |
SecretId | Key ID | AKIDPcY*****CVYLn3zT |
Timestamp | Current timestamp | 1534154812 |
SignatureMethod | Signature algorithm | HmacSHA1 |
Nonce | Random positive integer | 2889712707386595659 |
queueName | Name of the queue sending message | test1 |
RequestClient | Client version | SDK_Python_1.3 |
clientRequestId | Unique custom ID of client | 123***1231 |
delaySeconds | Delay time | 0 |
msgBody | Message content to be sent | msg |
Action
, SecretId
, Timestamp
, Nonce
, and SignatureMethod
) instead of the six ones described in "common request parameters". Actually, the sixth parameter Signature
(signature string) is generated by other parameters (including signaling request parameters) together in the following steps:ksort
function in PHP. The sorting results of the above sample parameters are as follows:Action=SendMessageNonce=2889712707386595659RequestClient=SDK_Python_1.3SecretId=AKIDPcY*****CVYLn3zTSignatureMethod=HmacSHA1Timestamp=1534154812clientRequestId=123***1231delaySeconds=0msgBody=msgqueueName=test1
parameter=value
. For example, for the Action
parameter, its parameter is Action
and its value is SendMessages
; therefore, the parameter will be formatted into Action=SendMessage
.value
is the original value instead of the URL-encoded value.&
. The generated request string will be as follows:Action=SendMessage&Nonce=2889712707386595659&RequestClient=SDK_Python_1.3&SecretId=AKIDPcY*****CVYLn3zT&SignatureMethod=HmacSHA1&Timestamp=1534154812&clientRequestId=123***1231&delaySeconds=0&msgBody=msg&queueName=test1
cmq-queue-gz.api.tencentyun.com
is requested./v2/index.php
.request method + request server + request path + ? + request string
.POSTcmq-queue-gz.api.tencentyun.com/v2/index.php?Action=SendMessage&Nonce=2889712707386595659&RequestClient=SDK_Python_1.3&SecretId=AKIDPcY*****CVYLn3zT&SignatureMethod=HmacSHA1&Timestamp=1534154812&clientRequestId=123***1231&delaySeconds=0&msgBody=msg&queueName=test1
$secretKey = 'pPgfLipfEXZ7VcRzhAMIyPaU7UbQyFFx';$srcStr = 'POSTcmq-queue-gz.api.tencentyun.com/v2/index.php?Action=SendMessage&Nonce=2889712707386595659&RequestClient=SDK_Python_1.3&SecretId=AKIDPcY*****CVYLn3zT&SignatureMethod=HmacSHA1&Timestamp=1534154812&clientRequestId=123***1231&delaySeconds=0&msgBody=msg&queueName=test1';$signStr = base64_encode(hash_hmac('sha1', $srcStr, $secretKey, true));echo $signStr;
C16WEtEXsD5v5tnaUMLAbZewXhI=
C16WEtEXsD5v5tnaUMLAbZewXhI=
, it will be encoded to C16WEtEXsD5v5tnaUMLAbZewXhI%3d
, and the final value of the Signature
request parameter will be C16WEtEXsD5v5tnaUMLAbZewXhI%3d
, which will be used to generate the final request URL.
The final request string is:clientRequestId=1231231231&Nonce=2889712707386595659&Timestamp=1534154812&msgBody=msg&Action=SendMessage&SignatureMethod=HmacSHA1&RequestClient=SDK_Python_1.3&Signature=C16WEtEXsD5v5tnaUMLAbZewXhI%3D&delaySeconds=0&SecretId=AKIDPcY*****CVYLn3zT&queueName=test1
Was this page helpful?