123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\library\Easemob;
- use app\common\library\Tenim;
- use think\Db;
- class Demo extends Api
- {
-
-
-
-
-
- protected $noNeedLogin = ['*'];
-
- protected $noNeedRight = ['test2'];
-
- public function yidong_sms(){
- $mobile = '18560505277';
- $content = '【淮安达富居家养老】您的短信验证码是1234,五分钟内有效';
- $url = 'https://112.35.1.155:443/sms/submit';
- $data = [
- 'ecName' => '江苏达富居家养老健康管理有限公司',
- 'apId' => 'dafuhttps',
- 'secretKey' => '&YY4vrJb',
- 'mobiles' => $mobile,
- 'content' => $content,
- 'sign' => 'YV61594FE',
- 'addSerial' => '',
- ];
- $mac = md5(join('',$data));
- $data['mac'] = $mac;
- unset($data['secretKey']);
- $header = ["Content-Type:application/json;charset=UTF-8"];
- $rs = curl_post($url,base64_encode(json_encode($data)),$header);
- dump($rs);
- $secretKey = '&YY4vrJb';
- }
-
- public function test()
- {
- $easemob = new Easemob();
- $rs = $easemob->user_create('doctor1');
- }
-
- public function test1()
- {
- $list = Db::name('user')->select();
- foreach($list as $key => $val){
- $tenim = new Tenim();
- $rs = $tenim->register('user'. $val['id'], $val['nickname'], '');
- dump($rs);
- }
- }
- public function test12()
- {
- $list = Db::name('doctor')->select();
- foreach($list as $key => $val){
- $tenim = new Tenim();
- $rs = $tenim->register('doctor'. $val['id'], $val['nickname'], '');
- dump($rs);
- }
- }
-
- public function test2()
- {
- $tenim = new Tenim();
- $order_id = 26;
- $message = [
- 'businessID' => 'order_status',
- 'name' => '待接单',
- 'status' => '10',
- 'id' => (string)$order_id,
- 'content' => '已通知医生尽快接诊,超时自动取消订单并退款',
- ];
- $rs = $tenim->sendCustomMessageToUser('user7','doctor7',$message);
- dump($rs);
- }
-
- public function test3()
- {
- $tv_userid = input('tv_userid');
- $tv_signtime = input('tv_signtime');
- $salt = 'be7bcf1499b0fec801406f6aafbd04c4';
- $get_sign = md5(md5($tv_userid) . $tv_signtime . $salt);
- dump($get_sign);
- }
- public function test4(){
- $wenzhen_order['user_id'] = 13;
-
- $tenim = new Tenim();
- $rs_online = $tenim->is_online('user'.$wenzhen_order['user_id']);
- if($rs_online != true){
- $this->error('患者现在不在线,请稍后拨打');
- }
- echo '在线';
- }
- public function test5(){
- $checkmap = [
- 'user_id' => 34,
- 'comefrom'=> 2,
- 'status' => ['IN','10,20,25,30'],
- ];
- $check_order = Db::name('wenzhen_order')->where($checkmap)->whereTime('createtime','month')->find();
- echo db()->getLastSql();
- }
-
-
- public function search_by_image($image = 'https://jiankangyijia-1304634122.cos.ap-nanjing.myqcloud.com/uploads/20240504/5cbfbb7880323f05839d82afe1500569.png'){
- $tencent_yun = config('tencent_yun');
- $secret_id = $tencent_yun['secret_id'];
- $secret_key = $tencent_yun['secret_key'];
- $token = "";
- $service = "tiia";
- $host = "tiia.tencentcloudapi.com";
- $req_region = "ap-beijing";
- $version = "2019-05-29";
- $action = "DetectProduct";
- $payload = json_encode(['ImageUrl' => localpath_to_netpath($image)]);
- $endpoint = "https://tiia.tencentcloudapi.com";
- $algorithm = "TC3-HMAC-SHA256";
- $timestamp = time();
- $date = gmdate("Y-m-d", $timestamp);
- $http_request_method = "POST";
- $canonical_uri = "/";
- $canonical_querystring = "";
- $ct = "application/json; charset=utf-8";
- $canonical_headers = "content-type:".$ct."\nhost:".$host."\nx-tc-action:".strtolower($action)."\n";
- $signed_headers = "content-type;host;x-tc-action";
- $hashed_request_payload = hash("sha256", $payload);
- $canonical_request = "$http_request_method\n$canonical_uri\n$canonical_querystring\n$canonical_headers\n$signed_headers\n$hashed_request_payload";
- $credential_scope = "$date/$service/tc3_request";
- $hashed_canonical_request = hash("sha256", $canonical_request);
- $string_to_sign = "$algorithm\n$timestamp\n$credential_scope\n$hashed_canonical_request";
- $secret_date = hash_hmac("sha256", $date, "TC3".$secret_key, true);
- $secret_service = hash_hmac("sha256", $service, $secret_date, true);
- $secret_signing = hash_hmac("sha256", "tc3_request", $secret_service, true);
- $signature = hash_hmac("sha256", $string_to_sign, $secret_signing);
- $authorization = "$algorithm Credential=$secret_id/$credential_scope, SignedHeaders=$signed_headers, Signature=$signature";
- $headers = [
- "Authorization" => $authorization,
- "Content-Type" => "application/json; charset=utf-8",
- "Host" => $host,
- "X-TC-Action" => $action,
- "X-TC-Timestamp" => $timestamp,
- "X-TC-Version" => $version
- ];
- if ($req_region) {
- $headers["X-TC-Region"] = $req_region;
- }
- if ($token) {
- $headers["X-TC-Token"] = $token;
- }
- $headers = array_map(function ($k, $v) { return "$k: $v"; }, array_keys($headers), $headers);
- try {
- $timeOut = 3;
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $endpoint);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeOut);
- curl_setopt($ch, CURLOPT_HEADER, 0);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- $response = curl_exec($ch);
- curl_close($ch);
-
- $response = json_decode($response,true);
- if(is_array($response) && isset($response['Response']['Products'][0]['Name'])){
- $searchname = $response['Response']['Products'][0]['Name'];
- if(!empty($searchname)){
- return $searchname;
- }
- }
- return '';
- } catch (Exception $err) {
-
- return '';
- }
- }
- }
|