zoukankan      html  css  js  c++  java
  • 阿里云人脸检测定位

    <?php
    header("content-type:text/html;charset=utf-8");
    $akId = '';
    $akSecret = '';
    //更新api信息
    //官方API   https://help.aliyun.com/knowledge_detail/53399.html
    $url = "https://dtplus-cn-shanghai.data.aliyuncs.com/face/detect";
    $rq_data['type']=0;
    $rq_data['image_url']='http://imgsrc.baidu.com/imgad/pic/item/38dbb6fd5266d01671f6f0dc9d2bd40734fa3552.jpg';
    $options = array(
        'http' => array(
            'header' => array(
                'accept'=> "application/json",
                'content-type'=> "application/json",
                'date'=> gmdate("D, d M Y H:i:s GMT"),
                'authorization' => ''
            ),
            'method' => "POST", //可以是 GET, POST, DELETE, PUT
            'content' => json_encode($rq_data) //如有数据,请用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']."
    ".$header['accept']."
    ".$bodymd5."
    ".$header['content-type']."
    ".$header['date']."
    ".$path;
    $signature = base64_encode(
        hash_hmac(
            "sha1",
            $stringToSign,
            $akSecret, true));
    $authHeader = "Dataplus "."$akId".":"."$signature";
    $options['http']['header']['authorization'] = $authHeader;
    $options['http']['header'] = implode(
        array_map(
            function($key, $val){
                return $key.":".$val."
    ";
            },
            array_keys($options['http']['header']),
            $options['http']['header']));
    $context = stream_context_create($options);
    $file = file_get_contents($url, false, $context );
    echo $file;
    ?>
    
  • 相关阅读:
    操作系统学习(一)、80x86保护模式内存管理
    Linux命令(十三) 建立目录 mkdir 删除目录 rmdir
    Linux命令(十二) 分割文件 split 合并文件 join
    Linux命令(十一) 显示文件类型 file
    linux下环境变量PS1设置
    Jenkins email-ext邮件通知模板
    building system busy, pls wait !!
    SCP 命令
    NDK Build 用法(NDK Build)
    android下m、mm、mmm编译命令的使用
  • 原文地址:https://www.cnblogs.com/mracale/p/9371972.html
Copyright © 2011-2022 走看看