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

修改微博登录后分享

@@ -463,6 +463,8 @@ class LoginController extends HomeBaseController @@ -463,6 +463,8 @@ class LoginController extends HomeBaseController
463 463
464 //微博分享 464 //微博分享
465 public function wb_share(){ 465 public function wb_share(){
  466 + $login = cmf_is_user_login();
  467 + if($login) {
466 $token = session('token'); 468 $token = session('token');
467 $title = $this->request->post('title');//分享标题 469 $title = $this->request->post('title');//分享标题
468 $share_url = $this->request->post('share_url');//分享url 470 $share_url = $this->request->post('share_url');//分享url
@@ -470,16 +472,19 @@ class LoginController extends HomeBaseController @@ -470,16 +472,19 @@ class LoginController extends HomeBaseController
470 $url = 'https://api.weibo.com/2/statuses/share.json'; 472 $url = 'https://api.weibo.com/2/statuses/share.json';
471 $data = [ 473 $data = [
472 'access_token' => $token, 474 'access_token' => $token,
473 - 'status' => $title." ".$share_url 475 + 'status' => $title . " " . $share_url
474 ]; 476 ];
475 - $res = $this->http_post($url,$data);  
476 - $json_arr = json_decode($res,true);  
477 - if(isset($json_arr['error_code'])&&!empty($json_arr['error_code'])){  
478 - $this->apiResponse(0,$json_arr['error']); 477 + $res = $this->http_post($url, $data);
  478 + $json_arr = json_decode($res, true);
  479 + if (isset($json_arr['error_code']) && !empty($json_arr['error_code'])) {
  480 + $this->apiResponse(0, $json_arr['error']);
479 } 481 }
480 $postModel = new PortalPostModel(); 482 $postModel = new PortalPostModel();
481 - $postModel->where('id',$article_id)->setInc('post_share_wb',1);  
482 - $this->apiResponse(1,'分享成功!'); 483 + $postModel->where('id', $article_id)->setInc('post_share_wb', 1);
  484 + $this->apiResponse(1, '分享成功!');
  485 + }else{
  486 + $this->apiResponse(0, '请使用微博登录后操作!');
  487 + }
483 } 488 }
484 489
485 //取消授权 490 //取消授权