|
...
|
...
|
@@ -9,42 +9,138 @@ use GuzzleHttp\Client; |
|
|
|
*/
|
|
|
|
class AyrShare
|
|
|
|
{
|
|
|
|
public $path = 'https://app.ayrshare.com/api';
|
|
|
|
public $path = 'https://app.ayrshare.com';
|
|
|
|
//api_key
|
|
|
|
public $api_key = 'G8GQW3X-XBTMGXW-QPDDZ9A-WE1Z5SB';
|
|
|
|
//系统设置
|
|
|
|
public $config = [
|
|
|
|
|
|
|
|
'facebook'=>'#best https://www.facebook.com',
|
|
|
|
'google'=>'#best https://www.google.com',
|
|
|
|
'instagram'=>'#best https://www.instagram.com',
|
|
|
|
'linkedin'=>'#best https://www.linkedin.com',
|
|
|
|
'twitter'=>'#best https://www.twitter.com',
|
|
|
|
'telegram'=>'#best https://www.telegram.com',
|
|
|
|
'tiktok'=>'#bestvideo',
|
|
|
|
];
|
|
|
|
//profile_key
|
|
|
|
public $profile_key = "-----BEGIN RSA PRIVATE KEY-----
|
|
|
|
MIICWgIBAAKBgGFatMeBeaw7QJrqmylMLZlwuuO0FA/EZg5/g7Rrqu+FgpwvFkJq
|
|
|
|
9twEZJY+aIdDH8/RVrCZQGR/xUxKw9v4ows+sLwi4g41m8KRKDXUcJwQvSlwsHAi
|
|
|
|
h9hPGZxDsRK0Nv4pZ7XqGgh0Wb0VypX/+Q1dhX9BnXQmvEKayk8GQWQxAgMBAAEC
|
|
|
|
gYAFqOJNnudV7fPpja4LjpQwEW+sATIRYJeWTC9587ByUE6xicM/hTxouhCm82Xc
|
|
|
|
Rzi4OjFR/vbRYOQ1dTtBtIi18fdRrseQNyR/N2NZjw1X8n5aZcw5NVaa3d3YTQNa
|
|
|
|
uzjnYF5eYSOD4pNKKIDc35VHdmvGCV/JXwQKMTgu1+4AAQJBAL5jjN3kvMKFF8vG
|
|
|
|
DyYR8k+wPG9iXAdR0HjVNB3OzxKVW0MTwM32pJBXCmF1MOziL8WC48VHQL48hVRa
|
|
|
|
52xRqAECQQCC53rrrOPhPCLIb6kBfgqnxCojqlUK9paFL7NYTPtLYcOajY6+NiKT
|
|
|
|
CG1gaOwZh4r34HF7I59l/Ds98Z4nQDwxAkAC4/oIiGeBQIoK8vfZ6R3XreJNAp5J
|
|
|
|
EinrG7mN1kz4iEH5c7xSpDL9agTjU+cpQYneIs2Yeit2d+7CSBsJXvgBAkBDFsfU
|
|
|
|
yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe
|
|
|
|
yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j
|
|
|
|
zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
|
|
|
|
-----END RSA PRIVATE KEY-----";
|
|
|
|
public $profile_key = '';
|
|
|
|
//设置请求头
|
|
|
|
public $headers = [
|
|
|
|
'Authorization' => 'Bearer ',
|
|
|
|
'Content-Type' => 'application/json',
|
|
|
|
// 'Accept-Encoding' => 'deflate, gzip',
|
|
|
|
];
|
|
|
|
//私钥
|
|
|
|
private $private_key = "-----BEGIN RSA PRIVATE KEY-----
|
|
|
|
MIICWgIBAAKBgGFatMeBeaw7QJrqmylMLZlwuuO0FA/EZg5/g7Rrqu+FgpwvFkJq
|
|
|
|
9twEZJY+aIdDH8/RVrCZQGR/xUxKw9v4ows+sLwi4g41m8KRKDXUcJwQvSlwsHAi
|
|
|
|
h9hPGZxDsRK0Nv4pZ7XqGgh0Wb0VypX/+Q1dhX9BnXQmvEKayk8GQWQxAgMBAAEC
|
|
|
|
gYAFqOJNnudV7fPpja4LjpQwEW+sATIRYJeWTC9587ByUE6xicM/hTxouhCm82Xc
|
|
|
|
Rzi4OjFR/vbRYOQ1dTtBtIi18fdRrseQNyR/N2NZjw1X8n5aZcw5NVaa3d3YTQNa
|
|
|
|
uzjnYF5eYSOD4pNKKIDc35VHdmvGCV/JXwQKMTgu1+4AAQJBAL5jjN3kvMKFF8vG
|
|
|
|
DyYR8k+wPG9iXAdR0HjVNB3OzxKVW0MTwM32pJBXCmF1MOziL8WC48VHQL48hVRa
|
|
|
|
52xRqAECQQCC53rrrOPhPCLIb6kBfgqnxCojqlUK9paFL7NYTPtLYcOajY6+NiKT
|
|
|
|
CG1gaOwZh4r34HF7I59l/Ds98Z4nQDwxAkAC4/oIiGeBQIoK8vfZ6R3XreJNAp5J
|
|
|
|
EinrG7mN1kz4iEH5c7xSpDL9agTjU+cpQYneIs2Yeit2d+7CSBsJXvgBAkBDFsfU
|
|
|
|
yYLxCJT7DN8dOK/VU6AVL1Luj3qNP+k2tB2GgNBzAWHK8ou9t2/3HU8DtofuikUe
|
|
|
|
yx8Cccca9B4OF8nBAkAgIUZKGmVNFcGnFFo55vSJInNXFo4HCJ2o4DunBORVtQ/j
|
|
|
|
zFePUMXy1bFghAfzNKlrc5XgH4ixeeMh3cDtU97K
|
|
|
|
-----END RSA PRIVATE KEY-----";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :参数构建
|
|
|
|
* @name :(创建子账户配置文件)post_create_profiles
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/5 15:16
|
|
|
|
*/
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
$this->headers['Authorization'] = $this->headers['Authorization'].$this->api_key;
|
|
|
|
public function post_create_profiles($data){
|
|
|
|
$param = [
|
|
|
|
'title'=>$data['title'],
|
|
|
|
];
|
|
|
|
$url = $this->path.'/api/profiles/profile';
|
|
|
|
return $this->http_click('post',$url,$param);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @name :(删除子账户配置文件)deleted_profiles
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/5 15:16
|
|
|
|
*/
|
|
|
|
public function deleted_profiles($data){
|
|
|
|
$param = [
|
|
|
|
'title'=>$data['title'],
|
|
|
|
'profileKey'=>$this->profile_key,
|
|
|
|
];
|
|
|
|
$url = $this->path.'/api/profiles/profile';
|
|
|
|
return $this->http_click('delete',$url,$param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(跳转第三方生成jwt令牌)post_generate_jwt
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/5 18:07 https://app.ayrshare.com/api/profiles/generateJWT
|
|
|
|
*/
|
|
|
|
public function post_generate_jwt($data,$domain = 'globalso'){
|
|
|
|
$param = [
|
|
|
|
'domain'=>$domain,
|
|
|
|
'privateKey'=>$this->private_key,
|
|
|
|
'profileKey'=>$data['profileKey'],
|
|
|
|
// 'logout'=>true
|
|
|
|
];
|
|
|
|
$url = $this->path.'/api/profiles/generateJWT';
|
|
|
|
return $this->http_click('post',$url,$param);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(获取指定api_key的配置文件)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 :(发帖)post_send_msg
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/8 9:22
|
|
|
|
* @param :platforms: "facebook", "fbg", "twitter",
|
|
|
|
* "linkedin", "instagram","youtube", "reddit" ,"telegram""
|
|
|
|
*/
|
|
|
|
public function post_send_msg($param){
|
|
|
|
$param = [
|
|
|
|
'post'=>$param['post'],//内容(帖子文本)
|
|
|
|
'platforms'=>$param['platforms'],//平台
|
|
|
|
'idempotencyKey'=>$param['idempotencyKey'],//帖子唯一id
|
|
|
|
'mediaUrls'=>$param['mediaUrls'],
|
|
|
|
];
|
|
|
|
//平台参数处理
|
|
|
|
$this->headers['Accept-Encoding'] = 'gzip';
|
|
|
|
$this->headers['Authorization'] = $this->headers['Authorization'].$param['profile_key'];
|
|
|
|
$url = $this->path.'/api/post';
|
|
|
|
return $this->http_click('posts',$url,$param,$this->headers);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(上传图片或视频到ayr_share)post_media_upload
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/8 9:47
|
|
|
|
* https://app.ayrshare.com/api/media/upload
|
|
|
|
*/
|
|
|
|
public function post_media_upload($data){
|
|
|
|
$param = [
|
|
|
|
'file'=>$data['file'],//base64编码
|
|
|
|
'fileName'=>$data['file_name'],//生成图片名称
|
|
|
|
'description'=>$data['description'],//描述
|
|
|
|
];
|
|
|
|
$this->headers['Authorization'] = $this->headers['Authorization'].$data['profile_key'];
|
|
|
|
$url = $this->path.'/api/media/upload';
|
|
|
|
return $this->http_click('posts',$url,$param,$this->headers);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
...
|
...
|
@@ -133,7 +229,7 @@ class AyrShare |
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/5 15:00
|
|
|
|
*/
|
|
|
|
public function post_user($data){
|
|
|
|
public function post_profiles($data){
|
|
|
|
$param = [
|
|
|
|
'post'=>$data['post'],
|
|
|
|
'platforms'=>$data['platforms'],
|
|
...
|
...
|
@@ -145,57 +241,6 @@ class AyrShare |
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name :(创建子账户相关操作)post_create_profiles
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/5 15:16
|
|
|
|
*/
|
|
|
|
public function post_create_profiles($data){
|
|
|
|
$param = [
|
|
|
|
'title'=>$data['title'],
|
|
|
|
];
|
|
|
|
$url = $this->path.'/profiles/profile';
|
|
|
|
return $this->http_click('post',$url,$param);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @name :(删除子账户相关操作)post_create_profiles
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/5 15:16
|
|
|
|
*/
|
|
|
|
public function deleted_create_profiles($data){
|
|
|
|
$param = [
|
|
|
|
'title'=>$data['title'],
|
|
|
|
'profileKey'=>$this->profile_key,
|
|
|
|
];
|
|
|
|
$url = $this->path.'/profiles/profile';
|
|
|
|
return $this->http_click('delete',$url,$param);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function put_update_profiles($data){
|
|
|
|
$param = [
|
|
|
|
'title'=>$data['title'],
|
|
|
|
'profileKey'=>$this->profile_key,
|
|
|
|
];
|
|
|
|
$url = $this->path.'/profiles/profile';
|
|
|
|
return $this->http_click('put',$url,$param);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @name :(获取有关用户社交资料的分析和人口统计,例如印象,视图和关注着)post_social
|
|
|
|
* @author :lyh
|
|
|
|
* @method :post
|
|
|
|
* @time :2023/5/5 10:37
|
|
|
|
*/
|
|
|
|
public function api_user(){
|
|
|
|
$post_data = [
|
|
|
|
'platforms' => ['facebook', 'instagram', 'twitter', 'linkedin', 'pinterest', 'youtube', 'tiktok'],
|
|
|
|
];
|
|
|
|
$url = $this->path.'/api/user';
|
|
|
|
return $this->http_click('post',$url,$post_data);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 发送http post,get,put,delete请求
|
|
|
|
* @param type $url
|
|
|
|
* @param type $post_data
|
|
...
|
...
|
@@ -205,13 +250,16 @@ class AyrShare |
|
|
|
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 {
|
|
|
|
$res = $client->request(strtoupper($method), $url, $post_data)->getBody()->getContents();
|
|
|
|
return $res;
|
|
|
|
return (array)json_decode($res);
|
|
|
|
} catch (\Exception $e) {
|
|
|
|
return json_encode(["status"=>"fail","message"=>$e->getMessage()]);
|
|
|
|
return ["status"=>"fail","message"=>$e->getMessage()];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} |
...
|
...
|
|