• 阿里云人脸检测定位


    <?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;
    ?>
    
  • 相关阅读:
    Pandas | 21 日期功能
    Pandas | 20 级联
    Pandas | 19 合并/连接
    Pandas | GroupBy 分组
    Pandas | 缺失数据处理
    Pandas | 16 聚合
    Pandas | 15 窗口函数
    Pandas | 14 统计函数
    Pandas | 13 索引和选择数据
    Pandas | 12 选项和自定义
  • 原文地址:https://www.cnblogs.com/mracale/p/9371972.html
Copyright © 2020-2023  润新知