Cloudcall.php
1.6 KB
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
<?php
namespace addons\facrm\controller;
use fast\Date;
use think\addons\Controller;
/**
* 云呼回调接口
* @icon fa fa-circle-o
*/
class Cloudcall extends Controller
{
protected $cacheCallName = "cache_call_engine_name";
protected $calltypes = [];
public function _initialize()
{
parent::_initialize();
$this->request->filter(['strip_tags']);
}
/**
* 通话记录回调
* @ApiParams(name="engine", type="string", required=true, description="通道")
* @ApiBody ("域名/addons/facrm/cloudcall/back?engine=通道(如Tycc100)")
* @ApidBody
*/
public function back($engine=null)
{
$engine=!$engine?$this->request->request('engine'):$engine;
$engine=!$engine?$this->request->route('engine'):"";
if (!$engine){
$this->error("通道不存在");
}
$this->setting = cache($this->cacheCallName.$engine);
if (!$this->setting) {
$this->key = "cloudcall";
$settingModel = new \app\admin\model\facrm\Setting();
$this->setting=$settingModel->where('key', "cloudcall".$engine)->find();
if (!$this->setting){
$this->error("通道不存在");
}
$this->setting=$this->setting->toArray();
cache($this->cacheCallName.$engine, $this->setting, 86400);//缓存一天
}
$this->setting['key'] = $this->setting['describe'];
$this->setting = array_merge($this->setting, $this->setting['values']);
$call= \addons\facrm\library\cloudcall\Call::instance($this->setting);
$result=$call->back();
}
}