<?php
$dateTime = gmdate("D, d M Y H:i:s T");
$SecretId = 'your SecretId';
$SecretKey = 'your SecretKey';
$srcStr = "date: ".$dateTime."\\n"."source: "."xxxxxx";
$Authen = 'hmac id="'.$SecretId.'", algorithm="hmac-sha1", headers="date source", signature="';
$signStr = base64_encode(hash_hmac('sha1', $srcStr, $SecretKey, true));
$Authen = $Authen.$signStr."\\"";
echo $Authen;
$url = 'http://service-xxxxxxxx-1234567890.ap-guangzhou.apigateway.myqcloud.com/release/yousa';
$headers = array(
'Host:service-xxxxxxxx-1234567890.ap-guangzhou.apigateway.myqcloud.com',
'Accept:text/html, */*; q=0.01',
'Source: xxxxxx',
'Date: '.$dateTime,
'Authorization: '.$Authen,
'X-Requested-With: XMLHttpRequest',
'X-NameSpace-Code: testmic',
'X-MicroService-Name: provider-demo'
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
$data = curl_exec($ch);
if (curl_errno($ch)) {
print "Error: " . curl_error($ch);
} else {
var_dump($data);
curl_close($ch);
}
?>
Was this page helpful?