>

测相仿度Wechat接口_php实例_脚本之家,附微信接口

- 编辑:澳门新葡亰平台游戏 -

测相仿度Wechat接口_php实例_脚本之家,附微信接口

人脸评分微信接口,获取微信图片地址,curl请求face++接口。解析json数据,计算颜值。返回用户。

微信入口绑定,微信事件处理,微信API全部操作包含在这些文件中。微信支付、微信红包、微信卡券、微信小店。

无论大转盘也好,或者是刮刮卡都是抽奖都可以利用同样的方法来计算中奖的概率和控制奖池的数量,本文为大家分享了PHP微信刮刮卡实例代码,PHP微信刮刮卡+接口,可直接调用,自带微信接口,供大家学习。

颜值匹配版,请到腾讯微校上体验。

  1. [代码]index.php

    wcValid();

  2. [代码]微信入口类

    token = $token; } public function wcCheckSignature(){ try{ if { throw new Exception('TOKEN is not defined!'); } $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = $this->token; $tmpArr = array($token, $timestamp, $nonce); // use SORT_STRING rule sort; $tmpStr = implode; $tmpStr = sha1; if( $tmpStr == $signature ){ return true; }else{ return false; } } catch { echo 'Message: ' .$e->getMessage(); } } public function wcValid(){ $echoStr = isset && !empty ? addslashes : NULL; if{ $this->wcMsg(); } else{ //valid signature , option if($this->wcCheckSignature{ echo $echoStr; exit; } else{ exit(); } } } public function wcMsg(){ //get post data, May be due to the different environments $postStr = isset($GLOBALS["HTTP_RAW_POST_DATA"]) && !empty($GLOBALS["HTTP_RAW_POST_DATA"]) ? $GLOBALS["HTTP_RAW_POST_DATA"] : ""; if{ libxml_disable_entity_loader; $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $this->zcLog; $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $MsgType = $postObj->MsgType; if{//执行事件相应 $Event = $postObj->Event; switch { case 'subscribe'://关注 break; case 'unsubscribe'://取消关注 break; case 'SCAN'://扫描 break; case 'LOCATION'://地址 break; case 'CLICK'://点击时间 break; case 'VIEW'://跳转 break; case 'card_pass_check'://卡券审核通过 break; case 'card_not_pass_check'://卡券审核失败 break; case 'user_get_card'://用户领取卡券 break; case 'user_del_card'://用户删除卡券 break; case 'user_view_card'://用户浏览会员卡 break; case 'user_consume_card'://用户核销卡券 break; case 'merchantorder'://微小店用户下单付款 break; default: break; } } else{ switch { case 'text'://文本格式 break; case 'image'://图片格式 break; case 'voice'://声音 break; case 'video'://视频 break; case 'shortvideo'://小视频 break; case 'location'://上传地理位置 break; case 'link'://链接相应 break; default: break; } } //////////////////////////////////////////////////////////////////// $keyword = trim; $time = time(); $textTpl = " %s 0 "; if{ $msgType = "text"; $contentStr = "Welcome to wechat world!"; $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr); echo $resultStr; } else{ echo "Input something..."; } //////////////////////////////////////////////////////////////////// } else{ echo "暂时没有任何信息!"; exit; } } //日志LOG public function zcLog{ $this->returnAy = array(); $this->returnAy['errcode'] = $errcode; $this->returnAy['errmsg'] = $errmsg; $this->returnAy['errtime'] = date; $logfile = fopen("logfile".date.".txt", "a+"); $txt = json_encode."n"; fwrite; fclose; //return $this->returnAy; } }

  3. [代码]微信操作类 - 更新了自定义菜单部分

    • @link @version 2.0.1 @uses $wxApi = new WxApi(); @package 微信API接口 陆续会继续进行更新 **/ class WxApi { //const appId = ""; //const appSecret = ""; const appId = ""; const appSecret = ""; //const mchid = ""; //商户号 //const privatekey = ""; //私钥 public $parameters = array(); public function __construct(){ } /** 微信提交API方法,返回微信指定JSON **/ public function wxHttpsRequest{ $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); if { curl_setopt($curl, CURLOPT_POST, 1); curl_setopt($curl, CURLOPT_POSTFIELDS, $data); } curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec; curl_close; return $output; } /** 微信带证书提交数据 - 微信红包使用 **/ public function wxHttpsRequestPem($url, $vars, $second=30,$aHeader=array; //超时时间 curl_setopt($ch,CURLOPT_TIMEOUT,$second); curl_setopt($ch,CURLOPT_RETURNTRANSFER, 1); //这里设置代理,如果有的话 //curl_setopt($ch,CURLOPT_PROXY, '10.206.30.98'); //curl_setopt($ch,CURLOPT_PROXYPORT, 8080); curl_setopt; curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false); //以下两种方式需选择一种 //第一种方法,cert 与 key 分别属于两个.pem文件 //默认格式为PEM,可以注释 curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM'); curl_setopt($ch,CURLOPT_SSLCERT,getcwd().'/apiclient_cert.pem'); //默认格式为PEM,可以注释 curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM'); curl_setopt($ch,CURLOPT_SSLKEY,getcwd().'/apiclient_key.pem'); curl_setopt($ch,CURLOPT_CAINFO,'PEM'); curl_setopt($ch,CURLOPT_CAINFO,getcwd; //第二种方式,两个文件合成一个.pem文件 //curl_setopt($ch,CURLOPT_SSLCERT,getcwd; if >= 1 ){ curl_setopt($ch, CURLOPT_HTTPHEADER, $aHeader); } curl_setopt; curl_setopt($ch,CURLOPT_POSTFIELDS,$vars); $data = curl_exec{ curl_close; return $data; } else { $error = curl_errno; echo "call faild, errorCode:$errorn"; curl_close; return false; } } /** 微信获取AccessToken 返回指定微信公众号的at信息 **/ public function wxAccessToken($appId = NULL , $appSecret = NULL){ $appId = is_null ? self::appId : $appId; $appSecret = is_null ? self::appSecret : $appSecret; $data = json_decode(file_get_contents; if ($data->expire_time < time { //echo $appId,$appSecret; $url = "; $result = $this->wxHttpsRequest; //print_r; $jsoninfo = json_decode; $access_token = $jsoninfo["access_token"]; if { $data->expire_time = time() + 7000; $data->access_token = $access_token; $fp = fopen("access_token.json", "w"); fwrite($fp, json_encode; } } else { $access_token = $data->access_token; } return $access_token; } /** 微信获取AccessToken 返回指定微信公众号的at信息 **/ public function wxJsApiTicket($appId = NULL , $appSecret = NULL){ $appId = is_null ? self::appId : $appId; $appSecret = is_null ? self::appSecret : $appSecret; $data = json_decode(file_get_contents; if ($data->expire_time < time { $url = "); $result = $this->wxHttpsRequest; $jsoninfo = json_decode; $ticket = $jsoninfo['ticket']; if { $data->expire_time = time() + 7000; $data->jsapi_ticket = $ticket; $fp = fopen("jsapi_ticket.json", "w"); fwrite($fp, json_encode; } } else { $ticket = $data->jsapi_ticket; } return $ticket; } /** 微信通过OPENID获取用户信息,返回数组 **/ public function wxGetUser{ $wxAccessToken = $this->wxAccessToken(); $url = ""; $result = $this->wxHttpsRequest; $jsoninfo = json_decode; return $jsoninfo; } /** 微信生成二维码ticket **/ public function wxQrCodeTicket{ $wxAccessToken = $this->wxAccessToken(); $url = "; $result = $this->wxHttpsRequest; return $result; } /** 微信通过ticket生成二维码 **/ public function wxQrCode{ $url = "" . urlencode; return $url; } /** 发送自定义的模板消息 **/ public function wxSetSend($touser, $template_id, $url, $data, $topcolor = '#7B68EE'){ $template = array( 'touser' => $touser, 'template_id' => $template_id, 'url' => $url, 'topcolor' => $topcolor, 'data' => $data ); $jsonData = json_encode; $result = $this->wxSendTemplate; return $result; } /** 微信设置OAUTH跳转URL,返回字符串信息 - SCOPE = snsapi_base //验证时不返回确认页面,只能获取OPENID **/ public function wxOauthBase($redirectUrl,$state = "",$appId = NULL){ $appId = is_null ? self::appId : $appId; $url = ""; return $url; } /** 微信设置OAUTH跳转URL,返回字符串信息 - SCOPE = snsapi_userinfo //获取用户完整信息 **/ public function wxOauthUserinfo($redirectUrl,$state = "",$appId = NULL){ $appId = is_null ? self::appId : $appId; $url = ""; return $url; } /** 微信OAUTH跳转指定URL **/ public function wxHeader{ header; } /** 微信通过OAUTH返回页面中获取AT信息 **/ public function wxOauthAccessToken($code,$appId = NULL , $appSecret = NULL){ $appId = is_null ? self::appId : $appId; $appSecret = is_null ? self::appSecret : $appSecret; $url = ""; $result = $this->wxHttpsRequest; //print_r; $jsoninfo = json_decode; //$access_token = $jsoninfo["access_token"]; return $jsoninfo; } /** 微信通过OAUTH的Access_Token的信息获取当前用户信息 // 只执行在snsapi_userinfo模式运行 **/ public function wxOauthUser{ $url = ""; $result = $this->wxHttpsRequest; $jsoninfo = json_decode; return $jsoninfo; } /** 创建自定义菜单 **/ public function wxMenuCreate{ $wxAccessToken = $this->wxAccessToken(); $url = "" . $wxAccessToken; $result = $this->wxHttpsRequest; $jsoninfo = json_decode; return $jsoninfo; } /** 获取自定义菜单 **/ public function wxMenuGet(){ $wxAccessToken = $this->wxAccessToken(); $url = "" . $wxAccessToken; $result = $this->wxHttpsRequest; $jsoninfo = json_decode; return $jsoninfo; } /** 删除自定义菜单 **/ public function wxMenuDelete(){ $wxAccessToken = $this->wxAccessToken(); $url = "" . $wxAccessToken; $result = $this->wxHttpsRequest; $jsoninfo = json_decode; return $jsoninfo; } /** 获取第三方自定义菜单 **/ public function wxMenuGetInfo(){ $wxAccessToken = $this->wxAccessToken(); $url = "" . $wxAccessToken; $result = $this->wxHttpsRequest; $jsoninfo = json_decode; return $jsoninfo; } /* 生成随机字符串 - 最长为32位字符串 **/ public function wxNonceStr($length = 16, $type = FALSE) { $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $str = ""; for ($i = 0; $i < $length; $i++) { $str .= substr($chars, mt_rand - 1), 1); } if{ return strtoupper; } else { return $str; } } /*** 微信商户订单号 - 最长28位字符串 **/ public function wxMchBillno { if{ if(self::mchid == "" || is_null{ $mchid = time(); } else{ $mchid = self::mchid; } } else{ $mchid = substr,0,10); } return date.$mchid; } /*** 微信格式化数组变成参数格式 - 支持url加密 **/ public function wxSetParam{ if && !empty{ $this->parameters = $parameters; return $this->parameters; } else{ return array(); } } /*** 微信格式化数组变成参数格式 - 支持url加密 **/ public function wxFormatArray($parameters = NULL, $urlencode = FALSE){ if{ $parameters = $this->parameters; } $restr = "";//初始化空 ksort;//排序参数 foreach ($parameters as $k => $v){//循环定制参数 if (null != $v && "null" != $v && "sign" != $k) { if{//如果参数需要增加URL加密就增加,不需要则不需要 $v = urlencode; } $restr .= $k . "=" . $v . "&";//返回完整字符串 } } if {//如果存在数据则将最后“&”删除 $restr = substr($restr, 0, strlen; } return $restr;//返回字符串 } /*** 微信MD5签名生成器 - 需要将参数数组转化成为字符串[wxFormatArray方法] **/ public function wxMd5Sign($content, $privatekey){ try { if { throw new Exception; } if { throw new Exception; } $signStr = $content . "&key=" . $privatekey; return strtoupper; } catch { die; } } /*** 微信Sha1签名生成器 - 需要将参数数组转化成为字符串[wxFormatArray方法] **/ public function wxSha1Sign{ try { if { throw new Exception; } //$signStr = $content; return sha1; } catch { die; } } /*** 微信jsApi整合方法 - 通过调用此方法获得jsapi数据 **/ public function wxJsapiPackage(){ $jsapi_ticket = $this->wxJsApiTicket(); // 注意 URL 一定要动态获取,不能 hardcode. $protocol = (!empty && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $url = $protocol.$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; $timestamp = time(); $nonceStr = $this->wxNonceStr(); $signPackage = array( "jsapi_ticket" => $jsapi_ticket, "nonceStr" => $nonceStr, "timestamp" => $timestamp, "url" => $url ); // 这里参数的顺序要按照 key 值 ASCII 码升序排序 $rawString = "jsapi_ticket=$jsapi_ticket&noncestr=$nonceStr×tamp=$timestamp&url=$url"; //$rawString = $this->wxFormatArray; $signature = $this->wxSha1Sign; $signPackage['signature'] = $signature; $signPackage['rawString'] = $rawString; $signPackage['appId'] = self::appId; return $signPackage; } /*** 将数组解析XML - 微信红包接口 **/ public function wxArrayToXml{ if{ $parameters = $this->parameters; } if(!is_array || empty{ die; } $xml = ""; foreach { if { $xml.="".$val."".$key.">"; } else $xml.="".$key.">"; } $xml.=""; return $xml; } /*** 微信卡券:上传LOGO - 需要改写动态功能 **/ public function wxCardUpdateImg() { $wxAccessToken = $this->wxAccessToken(); //$data['access_token'] = $wxAccessToken; $data['buffer'] = '@D:workspacehtdocsyky_testlogo.jpg'; $url = "; $result = $this->wxHttpsRequest; $jsoninfo = json_decode; return $jsoninfo; //array { ["url"]=> string "" } } /*** 微信卡券:获取颜色 **/ public function wxCardColor(){ $wxAccessToken = $this->wxAccessToken(); $url = "; $result = $this->wxHttpsRequest; $jsoninfo = json_decode; return $jsoninfo; } /*** 微信卡券:创建卡券 **/ public function wxCardCreated { $wxAccessToken = $this->wxAccessToken(); $url = "" . $wxAccessToken; $result = $this->wxHttpsRequest; $jsoninfo = json_decode; return $jsoninfo; } /*** 微信卡券:JSAPI 卡券Package - 基础参数没有附带任何值 - 再生产环境中需要根据实际情况进行修改 **/ public function wxCardPackage{ $timestamp = time(); $api_ticket = $this->wxJsApiTicket(); $cardId = $cardId; $arrays = array($api_ticket,$timestamp,$cardId); sort; $string = sha1; $resultArray['card_id'] = $cardId; $resultArray['card_ext'] = array(); $resultArray['card_ext']['openid'] = 'oOmn4s9MiwqHSNNvPn0dBtU23toA'; $resultArray['card_ext']['timestamp'] = $timestamp; $resultArray['card_ext']['signature'] = $string; return $resultArray; } }
  4. [代码]微信JSAPI

    wxOauthAccessToken; //print_r; // $openId = $Info['openid']; //} //////////////////////////////////////////// $signPackage = $wx->wxJsapiPackage(); //print_r; $kqInfo = $wx->wxCardPackage; $listInfo = $wx->wxCardListPackage();?> JSAPI接口测试

prize.php

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 { /* 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; $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA); $fromUsername = $postObj->FromUserName; $toUsername = $postObj->ToUserName; $keyword = trim; $imgUrl = $postObj->PicUrl; $Event = $postObj->Event; $EventKey = $postObj->EventKey; $MsgType = $postObj->MsgType; $time = time(); $itemTpl = "     "; if{ $item_str = sprintf($itemTpl, "颜值报告单", face, $imgUrl, MESSAGE_URL); $xmlTpl = "   %s  %s $item_str "; $resultStr = sprintf($xmlTpl, $fromUsername, $toUsername, $time, 1); echo $resultStr; } }else { echo ""; exit; } } private function checkSignature(){ // you must define TOKEN by yourself if { throw new Exception('TOKEN is not defined!'); } $signature = $_GET["signature"]; $timestamp = $_GET["timestamp"]; $nonce = $_GET["nonce"]; $token = TOKEN; $tmpArr = array($token, $timestamp, $nonce); // use SORT_STRING rule sort; $tmpStr = implode; $tmpStr = sha1; if( $tmpStr == $signature ){ return true; }else{ return false; } } } // 调用人脸识别的API返回识别结果function face{ // face++ 链接 $jsonStr =curl_get_contents(DETECT_URL.API_KEY.API_SECRET."&url=".$imgUrl.ATTRIBUTE); $replyDic = json_decode; $faceArray = $replyDic['face']; $resultStr = ""; for ($i= 0;$i< count{ $resultStr .= "n"; $tempFace = $faceArray[$i]; $faceId = $tempFace['face_id']; $tempAttr = $tempFace['attribute']; // 年龄:包含年龄分析结果 // value的值为一个非负整数表示估计的年龄, range表示估计年龄的正负区间 $tempAge = $tempAttr['age']; // 性别:包含性别分析结果 // value的值为Male/Female, confidence表示置信度 $tempGenger = $tempAttr['gender']; // 种族:包含人种分析结果 // value的值为Asian/White/Black, confidence表示置信度 $tempRace = $tempAttr['race']; // 微笑:包含微笑程度分析结果 //value的值为0-100的实数,越大表示微笑程度越高 $tempSmiling = $tempAttr['smiling']; // 返回性别 $sex=$tempGenger['value']; if { $resultStr .= "性别:男n"; } else if { $resultStr .= "性别:女n"; } //返回年龄 $maxAge = $tempAge['value'] + /2; $age=ceil; $resultStr .= "年龄:".$age."岁左右吧~ n"; //返回种族 if($tempRace['value'] === "Asian") { $resultStr .= "肤色:很健康哦~n"; } else if($tempRace['value'] === "White") { $resultStr .= "肤色:皮肤好白哟!^ 3^n"; } else if($tempRace['value'] === "Black") { $resultStr .= " 肤色:你有点黑?!!!n"; } //返回微笑度 $smiling = intval($tempSmiling['value']); $smile = round($tempSmiling['value'],3); $resultStr .= "微笑:".$smile."%n"; if{ //计算颜值 $yanzhi=getYanZhi; $resultStr .= "外貌协会专家评分:".$yanzhi."分nn"; $resultStr .= "xe2x9cxa8小编想说:n"; switch { case $yanzhi>94: $resultStr .="这颜值,爆表了!n"; break; case $yanzhi>87: $resultStr .="你这么好看,咋不上天呢!n"; break; case $yanzhi>82: $resultStr .="百看不厌,继续加油!n"; break; case $yanzhi>72: $resultStr .="还好,还能看!n"; break; case $yanzhi>67: $resultStr .="哎,只是丑的不明显!n"; break; case $yanzhi>62: $resultStr .="如果有钱,可以去整整!n"; break; default: $resultStr .="让我静静,你家没镜子么?n"; } } //图片中两个人时,计算相似度 if === 2){ // 获取face_id $tempFace1 = $faceArray[0]; $tempId1 = $tempFace1['face_id']; $tempFace2 = $faceArray[1]; $tempId2 = $tempFace2['face_id']; // face++ 链接 $jsonStr1 = curl_get_contents(COMPARE_URL.API_KEY.API_SECRET."&face_id2=".$tempId2 ."&face_id1=".$tempId1); $replyDic1 = json_decode; //取出相似程度 $tempResult = $replyDic1['similarity']; $tempSimilarity = $replyDic1['component_similarity']; $tempEye = $tempSimilarity['eye']; $tempEyebrow = $tempSimilarity['eyebrow']; $tempMouth = $tempSimilarity['mouth']; $tempNose = $tempSimilarity['nose']; $resultStr .= "n"; $resultStr .= "眼睛:".round."%n"; $resultStr .= "眉毛:".round."%n"; $resultStr .= "嘴巴:".round."%n"; $resultStr .= "鼻子:".round."%n"; $resultStr .= "nn两人相似程度:".round."%n"; if{ $resultStr .="哇塞!绝对的夫妻相了!n"; }elseif { $resultStr .="哎哟,长得挺像!你们快点在一起吧!n"; }else{ $resultStr .="0.0 长得不太一样哦。n"; } } //如果没有检测到人脸 if{ $resultStr = "对不起,俺没有识别出来,请换张正脸照试试=.="; } return $resultStr;} //颜值算法function getYanZhi{ $t1=microtime; $jsonStr = curl_get_contents(LANDMARK_URL.API_KEY.API_SECRET."&face_id=".$faceId.TYPE); $t2=microtime{ return 75.632; } if  { $replyDic = json_decode; $result = $replyDic['result']; $landmarkArry = $result[0]; $landmark =$landmarkArry['landmark']; $right_eyebrow_left_corner =$landmark['right_eyebrow_left_corner']; $left_eyebrow_right_corner =$landmark['left_eyebrow_right_corner']; $left_eye_left_corner =$landmark['left_eye_left_corner']; $left_eye_right_corner =$landmark['left_eye_right_corner']; $mouth_left_corner =$landmark['mouth_left_corner']; $mouth_right_corner =$landmark['mouth_right_corner']; $nose_left =$landmark['nose_left']; $nose_right =$landmark['nose_right']; $nose_contour_lower_middle =$landmark['nose_contour_lower_middle']; $right_eye_left_corner =$landmark['right_eye_left_corner']; $right_eye_right_corner =$landmark['right_eye_right_corner']; $contour_left1 =$landmark['contour_left1']; $contour_right1 =$landmark['contour_right1']; $contour_chin =$landmark['contour_chin']; $contour_left6 =$landmark['contour_left6']; $contour_right6 =$landmark['contour_right6']; //计算两眉头间的距离 $c1=distance($left_eyebrow_right_corner['x'],$left_eyebrow_right_corner['y'],$right_eyebrow_left_corner['x'],$right_eyebrow_left_corner['y']); //眉毛之间的中点坐标; $c1_x=($right_eyebrow_left_corner['x']-$left_eyebrow_right_corner['x'])/2+$left_eyebrow_right_corner['x']; $c1_y=($right_eyebrow_left_corner['y']-$left_eyebrow_right_corner['y'])/2+$left_eyebrow_right_corner['y']; //眉毛中点到鼻子最低处的距离 $c2 = distance($nose_contour_lower_middle['x'],$nose_contour_lower_middle['y'],$c1_x,$c1_y); //眼角之间的距离 $c3 = distance($left_eye_right_corner['x'],$left_eye_right_corner['y'],$right_eye_left_corner['x'],$right_eye_left_corner['y']); //鼻子的宽度 $c4 = distance($nose_left['x'],$nose_left['y'],$nose_right['x'],$nose_right['y']); //脸的宽度 $c5 = distance($contour_left1['x'],$contour_left1['y'],$contour_right1['x'],$contour_right1['y']); //下巴到鼻子下方的高度 $c6 = distance($contour_chin['x'],$contour_chin['y'],$nose_contour_lower_middle['x'],$nose_contour_lower_middle['y']); //眼睛的大小 $c7_left = distance($left_eye_left_corner['x'],$left_eye_left_corner['y'],$left_eye_right_corner['x'],$left_eye_right_corner['y']); $c7_right = distance($right_eye_left_corner['x'],$right_eye_left_corner['y'],$right_eye_right_corner['x'],$right_eye_right_corner['y']); //嘴巴的大小 $c8 = distance($mouth_left_corner['x'],$mouth_left_corner['y'],$mouth_right_corner['x'],$mouth_right_corner['y']); //嘴巴处的face大小 $c9 = distance($contour_left6['x'],$contour_left6['y'],$contour_right6['x'],$contour_right6['y']); /* 开始计算步骤 */ $yourmark = 100; $mustm = 0; //眼角距离为脸宽的1/5, $mustm += abs; //鼻子宽度为脸宽的1/5 $mustm += abs; //眼睛的宽度,应为同一水平脸部宽度的!/5 $eyepj = /2; $mustm += abs; //理想嘴巴宽度应为同一脸部宽度的1/2 $mustm += abs; //下巴到鼻子下方的高度 == 眉毛中点到鼻子最低处的距离 $mustm += abs; return round($yourmark-$mustm+$smiling/10,3); }else{ return 60; } } //两点之间的距离function distance{ return sqrt(abs + abs;} function curl_get_contents { $ch = curl_init(); curl_setopt( $ch , CURLOPT_URL,$url); curl_setopt( $ch , CURLOPT_RETURNTRANSFER,1); curl_setopt( $ch , CURLOPT_TIMEOUT,1); curl_setopt( $ch , CURLOPT_CONNECTTIMEOUT,1.5); $result = curl_exec; return $result;} ?>
     wx.config({ debug: false, appId: '&lt;&amp;#63;php echo $signPackage["appId"];&amp;#63;&gt;', timestamp: &lt;&amp;#63;php echo $signPackage["timestamp"];&amp;#63;&gt;, nonceStr: '&lt;&amp;#63;php echo $signPackage["nonceStr"];&amp;#63;&gt;', signature: '&lt;&amp;#63;php echo $signPackage["signature"];&amp;#63;&gt;', jsApiList: [ // &#25152;&#26377;&#35201;&#35843;&#29992;&#30340; API &#37117;&#35201;&#21152;&#21040;&#36825;&#20010;&#21015;&#34920;&#20013; 'onMenuShareTimeline', 'onMenuShareAppMessage', 'addCard', 'openCard' ] }); wx.ready { // &#22312;&#36825;&#37324;&#35843;&#29992; API wx.onMenuShareAppMessage({ title: '&#20114;&#32852;&#32593;&#20043;&#23376;', desc: '&#22312;&#38271;&#22823;&#30340;&#36807;&#31243;&#20013;&#65292;&#25105;&#25165;&#24930;&#24930;&#21457;&#29616;&#65292;&#25105;&#36523;&#36793;&#30340;&#25152;&#26377;&#20107;&#65292;&#21035;&#20154;&#36319;&#25105;&#35828;&#30340;&#25152;&#26377;&#20107;&#65292;&#37027;&#20123;&#25152;&#35859;&#26412;&#26469;&#22914;&#27492;&#65292;&#27880;&#23450;&#22914;&#27492;&#30340;&#20107;&#65292;&#23427;&#20204;&#20854;&#23454;&#27809;&#26377;&#38750;&#24471;&#22914;&#27492;&#65292;&#20107;&#24773;&#26159;&#21487;&#20197;&#25913;&#21464;&#30340;&#12290;&#26356;&#37325;&#35201;&#30340;&#26159;&#65292;&#26377;&#20123;&#20107;&#26082;&#28982;&#38169;&#20102;&#65292;&#37027;&#23601;&#35813;&#20570;&#20986;&#25913;&#21464;&#12290;', link: 'http://movie.douban.com/subject/25785114/', imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg', trigger: function  { // &#19981;&#35201;&#23581;&#35797;&#22312;trigger&#20013;&#20351;&#29992;ajax&#24322;&#27493;&#35831;&#27714;&#20462;&#25913;&#26412;&#27425;&#20998;&#20139;&#30340;&#20869;&#23481;&#65292;&#22240;&#20026;&#23458;&#25143;&#31471;&#20998;&#20139;&#25805;&#20316;&#26159;&#19968;&#20010;&#21516;&#27493;&#25805;&#20316;&#65292;&#36825;&#26102;&#20505;&#20351;&#29992;ajax&#30340;&#22238;&#21253;&#20250;&#36824;&#27809;&#26377;&#36820;&#22238; alert; }, success: function ; }, cancel: function ; }, fail: function  { alert; } }); document.querySelector.onclick = function () { wx.onMenuShareTimeline({ title: '&#20114;&#32852;&#32593;&#20043;&#23376;', link: 'http://movie.douban.com/subject/25785114/', imgUrl: 'http://demo.open.weixin.qq.com/jssdk/images/p2166127561.jpg', trigger: function  { // &#19981;&#35201;&#23581;&#35797;&#22312;trigger&#20013;&#20351;&#29992;ajax&#24322;&#27493;&#35831;&#27714;&#20462;&#25913;&#26412;&#27425;&#20998;&#20139;&#30340;&#20869;&#23481;&#65292;&#22240;&#20026;&#23458;&#25143;&#31471;&#20998;&#20139;&#25805;&#20316;&#26159;&#19968;&#20010;&#21516;&#27493;&#25805;&#20316;&#65292;&#36825;&#26102;&#20505;&#20351;&#29992;ajax&#30340;&#22238;&#21253;&#20250;&#36824;&#27809;&#26377;&#36820;&#22238; alert; }, success: function ; }, cancel: function ; }, fail: function  { alert; } }); }; document.querySelector.onclick = function () { wx.addCard({ cardList: [ { cardId: 'p7G0Cj_1HGF2nijO4sTlVTzawFhI', cardExt: '{"timestamp":"&lt;&amp;#63;php echo $kqInfo['cardExt']['timestamp'];&amp;#63;&gt;", "signature":"&lt;&amp;#63;php echo $kqInfo['cardExt']['signature'];&amp;#63;&gt;"}' } ], success: function  { var cardList = res.cardList; // &#28155;&#21152;&#30340;&#21345;&#21048;&#21015;&#34920;&#20449;&#24687; alert; }, cancel: function ; }, fail: function  { alert; } }); }; var shareData = { title: '&#24494;&#20449;JS-SDK Demo', desc: '&#24494;&#20449;JS-SDK,&#24110;&#21161;&#31532;&#19977;&#26041;&#20026;&#29992;&#25143;&#25552;&#20379;&#26356;&#20248;&#36136;&#30340;&#31227;&#21160;web&#26381;&#21153;', link: 'http://demo.open.weixin.qq.com/jssdk/', imgUrl: 'http://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRt8Qia4lv7k3M9J1SKqKCImxJCt7j9rHYicKDI45jRPBxdzdyREWnk0ia0N5TMnMfth7SdxtzMvVgXg/0' }; wx.onMenuShareAppMessage; wx.onMenuShareTimeline; var readyFunc = function onBridgeReady() { // &#32465;&#23450;&#20851;&#27880;&#20107;&#20214; document.querySelector.addEventListener { WeixinJSBridge.invoke('chooseCard', { "app_id": "&lt;&amp;#63;php echo $listInfo['app_id']&amp;#63;&gt;", "location_id ": '', "sign_type": "SHA1", "card_sign": "&lt;&amp;#63;php echo $listInfo['card_sign']&amp;#63;&gt;", "card_id": "&lt;&amp;#63;php echo $listInfo['card_id']&amp;#63;&gt;", "card_type": "&lt;&amp;#63;php echo $listInfo['card_type']&amp;#63;&gt;", "time_stamp": "&lt;&amp;#63;php echo $listInfo['time_stamp']&amp;#63;&gt;", "nonce_str": "&lt;&amp;#63;php echo $listInfo['nonce_str']&amp;#63;&gt;" }, function { alert(res.err_msg + res.choose_card_info); $.append(res.err_msg + res.choose_card_info); }); }); } if (typeof WeixinJSBridge === "undefined") { document.addEventListener('WeixinJSBridgeReady', readyFunc, false); } else { readyFunc(); }  
  刮刮卡                 奖项设置:     一等奖: iphone 5S 奖品数量:60   二等奖: ipad mini2 奖品数量:100   三等奖: 金士顿16G手机卡 奖品数量:2000        活动说明:    中奖用户请准确将收货地址发送给我,我们将以货到付款的方式邮寄给你!   亲,祝您好运哦!再来一次          window.sncode = "null"; $ { $.wScratchPad({ width: 150, height: 40, color: "#a9a9a7", }); });  
  1. [代码]创建卡券

    $kqinfo = array;$kqinfo['card']['card_type'] = 'GENERAL_COUPON';$kqinfo['card']['general_coupon'] = array('base_info' => array(), 'default_detail' => array;$kqinfo['card']['general_coupon']['base_info']['logo_url'] = 'URL';$kqinfo['card']['general_coupon']['base_info']['code_type'] = 'CODE_TYPE_QRCODE';$kqinfo['card']['general_coupon']['base_info']['brand_name'] = '';$kqinfo['card']['general_coupon']['base_info']['title'] = '测试卡券';$kqinfo['card']['general_coupon']['base_info']['color'] = 'Color030';$kqinfo['card']['general_coupon']['base_info']['notice'] = '测试测试测试';$kqinfo['card']['general_coupon']['base_info']['description'] = '这是一张优惠券';$kqinfo['card']['general_coupon']['base_info']['date_info']['type'] = 1;$kqinfo['card']['general_coupon']['base_info']['date_info']['begin_timestamp'] = time();$kqinfo['card']['general_coupon']['base_info']['date_info']['end_timestamp'] = time() + 100 24 3600;$kqinfo['card']['general_coupon']['base_info']['sku']['quantity'] = 100000;$kqinfo['card']['general_coupon']['default_detail'] = '测试数据n测试数据n测试数据'; //var_dump;//$kqinfo = json_encode;$kqinfo = C::enJson; //print_r;//$resultData = $wx->wxCardCreated;

以上所述就是本文的全部内容,希望大家能够喜欢。

本文由java编程发布,转载请注明来源:测相仿度Wechat接口_php实例_脚本之家,附微信接口