'text' , 'name'=>'APP_KEY', 'value'=>''), array('type'=>'text' , 'name' => 'APP_SECRET' , 'value' => ''), ); } if (!defined('WEBSITE')) { include_once(dirname(__FILE__).'/oath2.class.php'); class website extends oath2 { function website() { $this->app_key = APP_KEY; $this->app_secret = APP_SECRET; $this->tokenURL = 'https://api.weibo.com/oauth2/access_token'; $this->authorizeURL = 'https://api.weibo.com/oauth2/authorize'; $this->display = 'popup'; $this->userURL = 'https://api.weibo.com/2/users/show.json'; $this->meth = 'POST'; } function sign( &$p ){ $this->meth = 'GET'; $this->id_format($p['uid']); } function message($info) { $arr = array(); $arr['user_id'] = $info['id']; $arr['name'] = empty($info['screen_name']) ? $info['name'] : $info['screen_name']; $arr['location'] = $info['location']; $arr['sex'] = $info['gender'] == 'm' ? 1 : 0; $arr['img'] = empty($info['avatar_large']) ? '' : $info['avatar_large']; $arr['lang'] = $info['lang']; $arr['info'] = $info; return $arr; } public function is_error($result) // 错误 { $msg = json_decode($result , true); if(empty($msg['error_code'])) { return $msg; } if(is_array($msg)) $this->add_error($msg['error_code'] , $msg['error'], $msg['request'].' - '.(isset($msg['error_description']) ? $msg['error_description'] : '') . ' - ' .$str ); return false; } function id_format(&$id) { if ( is_float($id) ) { $id = number_format($id, 0, '', ''); } elseif ( is_string($id) ) { $id = trim($id); } } } } ?>