<?php
function b1Decode($p)
{
$a = urlencode($p);
$b = str_replace('+', '%20', $a);
$c = str_replace('*', '%2A', $b);
$d = str_replace('%7E', '~', $c);
return $d;
}
date_default_timezone_set('UTC');
$pubParams = array(
'Format' => 'JSON',
'Version' => '2015-11-23',
//
'AccessKeyId' => 'id',
// 'Signature' => '',
'SignatureMethod' => 'HMAC-SHA1',
'Timestamp' => date(DATE_ISO8601),
'SignatureVersion' => '1.0',
'SignatureNonce' => uniqid(),
'Action' => 'SingleSendMail',
//
'AccountName' => 'aaa@aaa',
'ReplyToAddress' => true,
'AddressType' => '1',
//
'ToAddress' => 'aaa@live.com',
'Subject' => '4',
'TextBody' => '4'
);
function getSign($pubParam)
{
$a = '';
foreach ($pubParam as $k => $v) {
if ($a == '') {
$a .= "{$k}=" . b1Decode($v);
} else {
$a .= "&{$k}=" . b1Decode($v);
}
}
return $a;
}
$StringToSign = 'POST&%2F&' . rawurlencode(str_replace('/', '%2F', getSign($pubParams)));
$Signature = base64_encode(hash_hmac("sha1", $StringToSign, 'sk' . '&', true));
$Signature = rawurlencode($Signature);
$url = "https://dm.aliyuncs.com/";
$post_data = 'Signature=' . $Signature . '&' . getSign($pubParams);
//print_r($post_data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
$output = curl_exec($ch);
curl_close($ch);
print_r($output);
-------------------------
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。