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

测试微博

@@ -448,14 +448,19 @@ class LoginController extends HomeBaseController @@ -448,14 +448,19 @@ class LoginController extends HomeBaseController
448 //微博分享 448 //微博分享
449 public function wb_share(){ 449 public function wb_share(){
450 $token = session('token'); 450 $token = session('token');
  451 + $title = $this->request->post('title');//分享标题
  452 + $share_url = $this->request->post('share_url');//分享url
451 $url = 'https://api.weibo.com/2/statuses/share.json'; 453 $url = 'https://api.weibo.com/2/statuses/share.json';
452 $data = [ 454 $data = [
453 'access_token' => $token, 455 'access_token' => $token,
454 - 'status' => URLencode('成功 http://www.starplanet.cn/portal/enjoy/getEnjoyDetail?id=52') 456 + 'status' => $title."  ".$share_url
455 ]; 457 ];
456 $res = $this->http_post($url,$data); 458 $res = $this->http_post($url,$data);
457 $json_arr = json_decode($res,true); 459 $json_arr = json_decode($res,true);
458 - var_dump($json_arr);exit; 460 + if(isset($json_arr['error_code'])&&!empty($json_arr['error_code'])){
  461 + $this->apiResponse(0,'分享失败!');
  462 + }
  463 + $this->apiResponse(1,'分享成功!');
459 } 464 }
460 465
461 //取消授权 466 //取消授权
@@ -183,7 +183,7 @@ $(function() { @@ -183,7 +183,7 @@ $(function() {
183 183
184 var share_url = encodeURIComponent(location.href); 184 var share_url = encodeURIComponent(location.href);
185 var share_title = encodeURIComponent(document.title); 185 var share_title = encodeURIComponent(document.title);
186 - //分享到微博 186 + //分享到微博弃用
187 $('.weibo').click(function() { 187 $('.weibo').click(function() {
188 var param = { 188 var param = {
189 url: share_url, 189 url: share_url,
@@ -197,8 +197,9 @@ $(function() { @@ -197,8 +197,9 @@ $(function() {
197 window.open('http://v.t.sina.com.cn/share/share.php?' + temp.join('&')); 197 window.open('http://v.t.sina.com.cn/share/share.php?' + temp.join('&'));
198 }); 198 });
199 199
200 - $('.weibo_share').click(function() {  
201 - $('#wb_share').submit(); 200 + //微博分享
  201 + $('#wb_share').click(function() {
  202 + thirdShare('/portal/login/wb_share');
202 }); 203 });
203 204
204 //微博登录 205 //微博登录
@@ -207,6 +208,29 @@ $(function() { @@ -207,6 +208,29 @@ $(function() {
207 }); 208 });
208 }); 209 });
209 210
  211 +//第三方分享
  212 +function thirdShare(url){
  213 + var title = $(document).attr("title");
  214 + var share_url = window.location.href;
  215 + $.ajax({
  216 + type: 'POST',
  217 + url: url,
  218 + data: {
  219 + 'title': title,
  220 + 'share_url': share_url
  221 + },
  222 + dataType: 'json',
  223 + async: false,
  224 + success: function(data) {
  225 + if (data.code == 1) {
  226 + mask(data.msg);
  227 + } else {
  228 + mask(data.msg);
  229 + }
  230 + }
  231 + });
  232 +}
  233 +
210 //点赞收藏 234 //点赞收藏
211 function operation(url, id) { 235 function operation(url, id) {
212 if (id == '' || id == undefined) { 236 if (id == '' || id == undefined) {
@@ -22,14 +22,8 @@ @@ -22,14 +22,8 @@
22 <p>168</p> 22 <p>168</p>
23 </div> 23 </div>
24 <!-- wb分享 --> 24 <!-- wb分享 -->
25 - <form action="/portal/login/wb_share" method="POST" id="wb_share">  
26 - <div class="wb_go weibo_share">  
27 - <img src="__TMPL__/public/assets/starImg/bicon_05.png" alt="">  
28 - <p>168</p>  
29 - </div>  
30 - <input type="hidden" name="client_id" value="737607150">  
31 - <input type="hidden" name="redirect_uri" value="http://www.xingqiu.cn/portal/login/wb_login">  
32 - <input type="hidden" name="flag" value="1">  
33 - </form>  
34 - 25 + <div class="wb_go weibo_share" id="wb_share">
  26 + <img src="__TMPL__/public/assets/starImg/bicon_05.png" alt="">
  27 + <p>168</p>
  28 + </div>
35 </div> 29 </div>