小程序获取access_token


// pages/token/token.js
Page({
  data: {

  },
  token:function(){
    wx.request({
      url: 'xxxx',
      data:{},
      success:function(res){
        console.log(res.data);
        //这里我是用的新浪云的sae,所以存在读写权限问题,打印出来的信息会存在告警
      }
    });
  }
})

{"access_token":"","expire_time":0}
expire_timeaccess_token;
    }
    return $access_token;
  }
  //公共的curl方法
  function httpGet($url){
    $curl = curl_init();
    curl_setopt($curl,CURLOPT_URL,$url);
    curl_setopt($curl,CURLOPT_RETURNTRANSFER,1);
    //如果用的是https,ssl安全验证
    curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
    curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
    $res =curl_exec($curl);
    curl_close($curl);
    return $res;
  }
  function get_php_file($filename){
    return trim(substr(file_get_contents($filename),15));
  }
  function set_php_file($filename,$content){
    $fp=fopen($filename,"w");
    fwrite($fp,"".$content);
    fclose($fp);
  }
  echo getAccessToken();
?>

 

你可能感兴趣的:(小程序)