颜值计算器(含微信接口)

<?php
/**
 * 人脸识别测颜值、测脸龄、测相似度微信接口
 * @Created by MOS.Ving.
 * @Author: MOS.Ving
 * @Mail 904679843@qq.com
 * @Date: 2016-01-31
 */
 
define("TOKEN", 'weixin');  //设置token
 
//FACE++ 参数  自行到face++官网注册并创建应用
define("API_KEY", "api_key=你的api_key"); //你的face++应用 api_key
define("API_SECRET", "&api_secret=你的api_secret");//你的face++应用 api_secret
define("ATTRIBUTE", "&attribute=glass,pose,gender,age,race,smiling");//需要返回的内容的参数
 
define("DETECT_URL", "http://apicn.faceplusplus.com/v2/detection/detect?");//检测给定图片(Image)中的所有人脸(Face)的位置和相应的面部属性api地址
define("LANDMARK_URL", "http://api.faceplusplus.com/detection/landmark?");//检测给定人脸(Face)相应的面部轮廓,五官等关键点的位置,包括25点和83点两种模式api地址
define("COMPARE_URL", "https://apicn.faceplusplus.com/v2/recognition/compare?");//计算两个Face的相似性以及五官相似度api地址
 
define("TYPE","&type=83p");//83点模式
 
 
define("MESSAGE_URL", "");//放回图文消息被点击需要跳转的地址,不需要跳转可不填
 
$wechatObj = new wechatCallbackapiTest();
if($_GET['echostr']){
    $wechatObj->valid();
}else{
    $wechatObj->responseMsg();
}
 
class wechatCallbackapiTest{
    public function valid(){
        $echoStr = $_GET["echostr"];
        //valid signature , option
        if($this->checkSignature()){
            echo $echoStr;
            exit;
        }
    }
 
    public function responseMsg(){
        //get post data, May be due to the different environments
        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
 
        //extract post data
        if (!empty($postStr)){
                /* libxml_disable_entity_loader is to prevent XML eXternal Entity Injection,
                   the best way is to check the validity of xml by yourself */
                libxml_disable_entity_loader(true);
                $postObj      = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
                $fromUsername = $postObj->FromUserName;
                $toUsername   = $postObj->ToUserName;
                $keyword      = trim($postObj->Content);
                $imgUrl       = $postObj->PicUrl;
                $Event        = $postObj->Event;
                $EventKey     = $postObj->EventKey;
                $MsgType      = $postObj->MsgType;
                $time         = time();
 
                $itemTpl = "<item>
                     <Title><![CDATA[%s]]></Title>
                     <Description><![CDATA[%s]]></Description>
                     <PicUrl><![CDATA[%s]]></PicUrl>
                     <Url><![CDATA[%s]]></Url>
                     </item>";
 
                if($MsgType == "image"){
                    $item_str = sprintf($itemTpl
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值