2019年7月

前端
$('#weibologin').click(function(){
    location.href = 'https://api.weibo.com/oauth2/authorize?client_id=1228667031&response_type=code&redirect_uri=http://new3.xuanwumobile.com/html/login_win.html';
  });
  var Request = new UrlSearch(); //实例化
  if(Request.code){
    $.ajax({
          url:'http://cloud.xuanwumobile.com/api/Timer/aaaaaa',
          data:'code='+Request.code,
          type:'post',
          cache:false,
          dataType:'json',
          success:function(ret) {
          if(ret.error){
            tanKuang('授权出错!');
            return;
          }else{
            var wbtoken = ret.uid;
            alert(wbtoken)
          }
        
           },
           error : function(err) {
            alert(err);
           }

           });
  }
  function UrlSearch() {
          var name, value;
          var str = location.href; //取得整个地址栏
          var num = str.indexOf("?")
          str = str.substr(num + 1); //取得所有参数   stringvar.substr(start [, length ]

          var arr = str.split("&"); //各个参数放到数组里
          for (var i = 0; i < arr.length; i++) {
              num = arr[i].indexOf("=");
              if (num > 0) {
                  name = arr[i].substring(0, num);
                  value = arr[i].substr(num + 1);
                  this[name] = value;
              }
          }
      }
后端
header("Access-Control-Allow-Origin: *");
        $code = $_REQUEST['code'];
        $body_json = array( //不能用,得把参数放到url里,方法是post,但form-data是空,否则报错:miss client id or secret
            'client_id' => '1228667031',
            'client_secret' => '2363c310edc1c847fa80a4feedcb211b',
            'grant_type' => 'authorization_code',
            'code' => $code,
            'redirect_uri' => 'http://new3.xuanwumobile.com/html/login_win.html'
        );
        $body = json_encode($body_json);
        $header = array(
            'Accept:application/json',
            'Content-Type:application/json;charset=utf-8',
        );
        //$url = 'https://api.weibo.com/oauth2/access_token';
        $url = 'https://api.weibo.com/oauth2/access_token?client_id=1228667031&client_secret=XXXXXXXXXXXX&grant_type=authorization_code&redirect_uri=http://new3.xuanwumobile.com/html/login_win.html&code=' . $code;
        $ch = curl_init($url);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, false);//formdata为false(即以前的$body_json )
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
        $result = curl_exec($ch);
        curl_close($ch);
        $res = json_decode($result, true);
        return json($res);

通过controlslist和禁止右键使播放器不能被下载

<video src="{$data.h_video}" class="swiper-slide-img" id="qqq" controls controlslist="nodownload  nofullscreen noremoteplayback" oncontextmenu = "return false">
    您的浏览器不支持 video 标签。
</video>

但是在谷歌浏览器下右下角有个仨点的功能(下载和画中画),画中画去不掉,通过js的方法去掉:

var video = $('#qqq');
//console.log(video); //通过打印拿到所有的属性和方法
video[0]['disablePictureInPicture'] = true; //disablePictureInPicture的属性改为true

没有了下载和画中画,仨点就消失了