$akId = "LTAIiaToKXXXuzRJ";
$akSecret = "U78YwGydQ1XXXXX4a7hkJtKIlyMszA";
//更新api信息
$url = "https://nlsapi.aliyun.com/transcriptions";
$tempArray = array(
'app_key' => 'nls-service-telephone8khz',
'oss_link' => 'http://audiocheck.oss-cn-shanghai.aliyuncs.com/1499772383-sip28x886986518999-886277083858-101.mp3'
);
$options = array(
'http' => array(
'header' => array(
'Accept'=> "application/json",
'Content-Type'=> "application/json",
'date'=> gmdate("D, d M Y H:i:s \G\M\T"),
'Authorization' => ''
),
'method' => "POST", //可以是 GET, POST, DELETE, PUT
'content' => json_encode($tempArray) //如有数据,请用json_encode()进行编码
)
);
$http = $options['http'];
$header = $http['header'];
$urlObj = parse_url($url);
if(empty($urlObj["query"]))
$path = $urlObj["path"];
else
$path = $urlObj["path"]."?".$urlObj["query"];
$body = $http['content'];
if(empty($body))
$bodymd5 = $body;
else
$bodymd5 = base64_encode(md5($body,true));
$stringToSign = $http['method']."n".$header['Accept']."\n".$bodymd5."n".$header['Content-Type']."\n".$header['date'];
$signature = base64_encode(
hash_hmac(
"sha1",
$stringToSign,
$akSecret, true));
$authHeader = "Dataplus "."$akId".":"."$signature";
$options['http']['header']['Authorization'] = $authHeader;
$options'http' = implode(
array_map(
function($key, $val){
return $key.":".$val."\r\n";
},
array_keys($options['http']['header']),
$options['http']['header']));
$context = stream_context_create($options);
$file = file_get_contents($url, false, $context );
echo($file);
以上除了id 跟key我遮 掉 了其餘未改奇怪的是 post 出去 一 直拿到 403不知是 我那裡錯了呢
?>
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。