public function testLogin()
 {
     $client_id = C('CLIENT_ID');
     $client_secret = C('CLIENT_SECRET');
     $config = array('client_id' => $client_id, 'client_secret' => $client_secret);
     $client = new OAuth2ClientService($config);
     $access_token = $client->getAccessToken();
     if ($access_token['status']) {
         $this->assign("access_token", $access_token['info']);
     }
     $this->assign("error", $access_token);
     $this->display();
 }
 public function __construct()
 {
     parent::__construct();
     $client_id = C('CLIENT_ID');
     $client_secret = C('CLIENT_SECRET');
     $config = array('client_id' => $client_id, 'client_secret' => $client_secret, 'site_url' => C("SITE_URL"));
     $client = new OAuth2ClientService($config);
     $access_token = $client->getAccessToken();
     if ($access_token['status']) {
         $this->assign("access_token", $access_token['info']);
     }
     $this->assign("error", $access_token);
 }
 /**
  * 取得accessToken
  * @return mixed
  */
 public function getAccessToken()
 {
     $access_token = S('boye_access_token');
     if (empty($access_token)) {
         $client_id = CLIENT_ID;
         $client_secret = CLIENT_SECRET;
         $config = array('client_id' => $client_id, 'client_secret' => $client_secret, 'site_url' => C("SITE_URL"));
         $client = new OAuth2ClientService($config);
         $access_token = $client->getAccessToken();
         $access_token = $access_token['info'];
         S('boye_access_token', $access_token, 60 * 18);
     }
     return $access_token['access_token'];
 }