作者 景龙
1 个管道 的构建 通过 耗费 1 秒

修改微博登录后分享

... ... @@ -463,23 +463,28 @@ class LoginController extends HomeBaseController
//微博分享
public function wb_share(){
$token = session('token');
$title = $this->request->post('title');//分享标题
$share_url = $this->request->post('share_url');//分享url
$article_id = $this->request->post('id');//分享文章id
$url = 'https://api.weibo.com/2/statuses/share.json';
$data = [
'access_token' => $token,
'status' => $title." ".$share_url
];
$res = $this->http_post($url,$data);
$json_arr = json_decode($res,true);
if(isset($json_arr['error_code'])&&!empty($json_arr['error_code'])){
$this->apiResponse(0,$json_arr['error']);
$login = cmf_is_user_login();
if($login) {
$token = session('token');
$title = $this->request->post('title');//分享标题
$share_url = $this->request->post('share_url');//分享url
$article_id = $this->request->post('id');//分享文章id
$url = 'https://api.weibo.com/2/statuses/share.json';
$data = [
'access_token' => $token,
'status' => $title . " " . $share_url
];
$res = $this->http_post($url, $data);
$json_arr = json_decode($res, true);
if (isset($json_arr['error_code']) && !empty($json_arr['error_code'])) {
$this->apiResponse(0, $json_arr['error']);
}
$postModel = new PortalPostModel();
$postModel->where('id', $article_id)->setInc('post_share_wb', 1);
$this->apiResponse(1, '分享成功!');
}else{
$this->apiResponse(0, '请使用微博登录后操作!');
}
$postModel = new PortalPostModel();
$postModel->where('id',$article_id)->setInc('post_share_wb',1);
$this->apiResponse(1,'分享成功!');
}
//取消授权
... ...