source = new stdClass(); $this->target = new stdClass(); $this->website = $website; $this->initSourceConfig(); $this->initTarget(); } //获得当前绑定的站点 public function getCurrentSite(){ return $this->website; } //设置绑定的站点 public function setCurrentSite($website){ $this->website = $website; $this->initSourceConfig(); } private function initSourceConfig() { if(!in_array($this->website,$this->sourceType)) { return false; } // Escience // passport.escience.cn $this->source->escience = new stdClass(); $this->source->escience->param = array( "id" => "client_id", "secret" => "client_secret", "code_response" => "response_type", "grant_type" => "grant_type", "callback" => "redirect_uri", "code"=>"code" ); //新浪微博(新浪通行证) $this->source->sina = new stdClass(); $this->source->sina->param = array( ); if($this->website == 'poles'){ $this->source->escience->config = array( 'id' => '74385', 'secret' => 'CVKqrnBQbg6dJmlIFdidZgtWBMKbDoNM', 'index' => 'http://www.poles.ac.cn', 'callback' => 'http://www.poles.ac.cn/account/callback/type/escience', 'other' => array( 'theme'=>'full' ) ); } if($this->website == 'westdc'){ $this->source->escience->config = array( 'id' => '71852', 'secret' => 'ad7gd3jZgbzhQM6vIh9vPnQFZQoTGHZI', 'index' => 'http://westdc.westgis.ac.cn', 'callback' => 'http://westdc.westgis.ac.cn/account/callback/type/escience', 'other' => array( 'theme'=>'full' ) ); } if($this->website == 'heihedata'){ $this->source->escience->config = array( 'id' => '78969', 'secret' => 'iTGKdCkUPakA2hza2TJ4XZ4cnwlh8Hqz', 'index' => 'http://www.heihedata.org', 'callback' => 'http://www.heihedata.org/account/callback/type/escience', 'other' => array( 'theme'=>'full' ) ); } if($this->website == 'card'){ $this->source->escience->config = array( 'id' => '58176', 'secret' => 'ZM5dEFX5GpJC62IcJ3iajx51T9hzhJkQ', 'index' => 'http://card.westgis.ac.cn/', 'callback' => 'http://card.westgis.ac.cn/account/callback/type/escience', 'other' => array( 'theme'=>'full' ) ); } } //Oauth2登录目标 /* name : 名称 code : 获取code的url token : 获取 token的url code_response : 获取token时使用的参数值(配合$this->source->OBJECTIVE->param中的code_response使用 grant_type : 获得token的认证方式,按照oauth2标准,应该是authorization_code */ private function initTarget(){ //中国科技网通行证 $this->target->escience = array( 'name' => '中国科技网通行证', 'code' => 'https://passport.escience.cn/oauth2/authorize', 'token' => 'https://passport.escience.cn/oauth2/token', 'code_response' => 'code', 'grant_type' => 'authorization_code', ); //新浪 $this->target->sina = array( 'name' => '新浪微博', 'code' => 'https://api.weibo.com/oauth2/authorize', 'token' => '', 'code_response' => 'code', 'grant_type' => 'authorization_code' ); } //获得一个源 public function getSource($type = "") { if(empty($type)) { return $this->source; }else{ if(isset($this->source->$type)) { return $this->source->$type; }else{ return false; } } } //获得Oauth2登录模板 public function getTarget($type = "") { if(empty($type)) { return $this->target; }else{ if(isset($this->target->$type)) { return $this->target->$type; }else{ return false; } } } }