作者 lyh

gx

... ... @@ -39,13 +39,6 @@ yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe
yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j
zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
-----END RSA PRIVATE KEY-----";
/**
* @name :参数构建
*/
public function __construct()
{
$this->headers['Authorization'] = $this->headers['Authorization'].$this->api_key;
}
/**
* @name :(创建子账户配置文件)post_create_profiles
... ... @@ -99,7 +92,20 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
* @time :2023/5/6 16:01
*/
public function get_profiles(){
$url = $this->path.'/api/profiles';
return $this->http_click('get',$url,[]);
}
/**
* @name :(获取所有用户的配置文件)get_profiles_users
* @author :lyh
* @method :post
* @time :2023/5/6 16:44
*/
public function get_profiles_users($api_key){
$this->headers['Authorization'] = $this->headers['Authorization'].$api_key;
$url = $this->path.'/api/user';
return $this->http_click('get',$url,[],$this->headers);
}
/**
* @name :(通过用户名获取社交账号)get_brand_user
... ... @@ -223,6 +229,9 @@ zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
if(!empty($param)){
$post_data['json'] = $param;
}
if(empty($header)){
$this->headers['Authorization'] = $this->headers['Authorization'].$this->api_key;
}
$post_data['headers'] = !empty($header) ? $header : $this->headers;
$client = new Client();
try {
... ...
... ... @@ -21,6 +21,10 @@ class AyrShareController extends BaseController
*/
public function lists(AyrShareModel $ayrShareModel){
$lists = $ayrShareModel->lists($this->map,$this->page,$this->row,'id',['*']);
$ayrShareHelper = new AyrShareHelper();
foreach ($lists['list'] as $k=>$v){
$lists['list'][$k]['ayr'] = $ayrShareHelper->get_profiles_users($v['profile_key']);
}
$this->response('列表',Code::SUCCESS,$lists);
}
... ... @@ -88,7 +92,6 @@ class AyrShareController extends BaseController
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$data = [
'domain'=>'develop.globalso.com',
'profileKey'=>$info['profile_key']
];
$res = $ayrShareHelper->post_generate_jwt($data);
... ... @@ -97,4 +100,31 @@ class AyrShareController extends BaseController
}
$this->response('success',Code::SUCCESS,$res);
}
/**
* @name :(获取当前用户的配置文件)get_profiles
* @author :lyh
* @method :post
* @time :2023/5/6 16:39
*/
public function get_profiles(AyrShareLogic $ayrShareLogic){
$this->request->validate([
'id'=>['required']
],[
'id.required' => 'ID不能为空'
]);
$info = $ayrShareLogic->ayr_share_info();
//发送请求注册社交用户
$ayrShareHelper = new AyrShareHelper();
$data = [
'title'=>$info['title'],
'refId'=>$info['ref_id'],
'profileKeys'=>$info['profile_keys']
];
$res = $ayrShareHelper->post_generate_jwt($data);
if($res['status'] == 'fail'){
$this->response($res['message'],Code::USER_ERROR);
}
$this->response('success',Code::SUCCESS,$res);
}
}
... ...
... ... @@ -24,14 +24,15 @@ class AyrShareLogic extends BaseLogic
*/
public function ayr_share_add($res){
//插入数据库
$this->param = [
$param = [
'title'=>$res['title'],
'ref_id'=>$res['refId'],
'profile_key'=>$res['profileKey'],
'user_id'=>$this->user['id'],
'project_id'=>$this->user['project_id'],
'name'=>$this->param['name'],
];
$rs = $this->model->add($this->param);
$rs = $this->model->add($param);
if($rs === false){
$this->fail('error');
}
... ...