缺点价格相当贵
带有天天p图水印
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
<?php header("Content-Type: text/html;charset=UTF-8"); // 图片base64编码 $path = 'https://yyb.gtimg.com/aiplat/ai/upload/demo/large/facemerge-demo3.jpg'; $data = file_get_contents($path); $base64 = base64_encode($data); // 设置请求数据 $appkey = '******'; $params = array( 'app_id' => '******', 'image' => $base64, 'model' => '5', 'time_stamp' => strval(time()), 'nonce_str' => strval(rand()), 'sign' => '', ); $params['sign'] = getReqSign($params, $appkey); // 执行API调用 $url = 'https://api.ai.qq.com/fcgi-bin/ptu/ptu_facemerge'; $response = doHttpPost($url, $params); $img = json_decode($response,true); if($img['ret']!='4096'){ $img = "<img src='data:image/jpg;base64,".$img['data']['image']."'/>'"; // $img = base64_decode($img); echo $img; } // - 签名结果 function getReqSign($params /* 关联数组 */, $appkey /* 字符串*/) { // 1. 字典升序排序 ksort($params); // 2. 拼按URL键值对 $str = ''; foreach ($params as $key => $value) { if ($value !== '') { $str .= $key . '=' . urlencode($value) . '&'; } } // 3. 拼接app_key $str .= 'app_key=' . $appkey; // 4. MD5运算+转换大写,得到请求签名 $sign = strtoupper(md5($str)); return $sign; } function doHttpPost($url, $params) { $curl = curl_init(); $response = false; do { // 1. 设置HTTP URL (API地址) curl_setopt($curl, CURLOPT_URL, $url); // 2. 设置HTTP HEADER (表单POST) $head = array( 'Content-Type: application/x-www-form-urlencoded' ); curl_setopt($curl, CURLOPT_HTTPHEADER, $head); // 3. 设置HTTP BODY (URL键值对) $body = http_build_query($params); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, $body); // 4. 调用API,获取响应结果 curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_NOBODY, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curl); if ($response === false) { $response = false; break; } $code = curl_getinfo($curl, CURLINFO_HTTP_CODE); if ($code != 200) { $response = false; break; } } while (0); curl_close($curl); return $response; } ?> |

我的微信
把最实用的经验,分享给最需要的读者,希望每一位来访的朋友都能有所收获!
2020年2月19日 上午10:36 1F
买单号 买快递单号 买空包 找空包代发选爱查www.aickd.com