├── .gitignore ├── LICENSE ├── Oauth2.php ├── README.md ├── example ├── application │ ├── cache │ │ └── index.html │ ├── config │ │ ├── autoload.php │ │ ├── config.php │ │ ├── constants.php │ │ ├── database.php │ │ ├── doctypes.php │ │ ├── foreign_chars.php │ │ ├── hooks.php │ │ ├── index.html │ │ ├── memcached.php │ │ ├── migration.php │ │ ├── mimes.php │ │ ├── oauth2.php │ │ ├── profiler.php │ │ ├── routes.php │ │ ├── smileys.php │ │ └── user_agents.php │ ├── controllers │ │ ├── index.html │ │ ├── logout.php │ │ ├── sns.php │ │ └── welcome.php │ ├── core │ │ └── index.html │ ├── helpers │ │ └── index.html │ ├── hooks │ │ └── index.html │ ├── index.html │ ├── language │ │ └── english │ │ │ └── index.html │ ├── libraries │ │ ├── Oauth2.php │ │ ├── index.html │ │ └── oauth2 │ │ │ ├── Exception.php │ │ │ ├── OAuth2.php │ │ │ ├── Provider.php │ │ │ ├── Provider │ │ │ ├── 10086.php │ │ │ ├── 163.php │ │ │ ├── 360.php │ │ │ ├── Baidu.php │ │ │ ├── Douban.php │ │ │ ├── Duoshuo.php │ │ │ ├── Feixin.php │ │ │ ├── Kaixin.php │ │ │ ├── Qq.php │ │ │ ├── Renren.php │ │ │ ├── Sohu.php │ │ │ ├── Taobao.php │ │ │ ├── Tianyi.php │ │ │ ├── Tweibo.php │ │ │ ├── Weibo.php │ │ │ ├── Weixin.php │ │ │ └── beyond the wall │ │ │ │ ├── Appnet.php │ │ │ │ ├── Blooie.php │ │ │ │ ├── Facebook.php │ │ │ │ ├── Foursquare.php │ │ │ │ ├── Github.php │ │ │ │ ├── Google.php │ │ │ │ ├── Instagram.php │ │ │ │ ├── Mailchimp.php │ │ │ │ ├── Mailru.php │ │ │ │ ├── Paypal.php │ │ │ │ ├── Soundcloud.php │ │ │ │ ├── Vkontakte.php │ │ │ │ ├── Windowslive.php │ │ │ │ └── Yandex.php │ │ │ ├── Token.php │ │ │ ├── Token │ │ │ ├── Access.php │ │ │ └── Authorize.php │ │ │ └── index.html │ ├── logs │ │ └── index.html │ ├── models │ │ └── index.html │ ├── third_party │ │ └── index.html │ └── views │ │ ├── errors │ │ ├── error_404.php │ │ ├── error_db.php │ │ ├── error_general.php │ │ ├── error_php.php │ │ └── index.html │ │ ├── index.html │ │ └── welcome_message.php ├── bd_dc241d3dd58dc598.txt ├── config.yaml ├── index.php ├── license.txt ├── system │ ├── core │ │ ├── Benchmark.php │ │ ├── CodeIgniter.php │ │ ├── Common.php │ │ ├── Config.php │ │ ├── Controller.php │ │ ├── Exceptions.php │ │ ├── Hooks.php │ │ ├── Input.php │ │ ├── Lang.php │ │ ├── Loader.php │ │ ├── Log.php │ │ ├── Model.php │ │ ├── Output.php │ │ ├── Router.php │ │ ├── Security.php │ │ ├── URI.php │ │ ├── Utf8.php │ │ └── index.html │ ├── database │ │ ├── DB.php │ │ ├── DB_cache.php │ │ ├── DB_driver.php │ │ ├── DB_forge.php │ │ ├── DB_query_builder.php │ │ ├── DB_result.php │ │ ├── DB_utility.php │ │ ├── drivers │ │ │ ├── cubrid │ │ │ │ ├── cubrid_driver.php │ │ │ │ ├── cubrid_forge.php │ │ │ │ ├── cubrid_result.php │ │ │ │ ├── cubrid_utility.php │ │ │ │ └── index.html │ │ │ ├── ibase │ │ │ │ ├── ibase_driver.php │ │ │ │ ├── ibase_forge.php │ │ │ │ ├── ibase_result.php │ │ │ │ ├── ibase_utility.php │ │ │ │ └── index.html │ │ │ ├── index.html │ │ │ ├── mssql │ │ │ │ ├── index.html │ │ │ │ ├── mssql_driver.php │ │ │ │ ├── mssql_forge.php │ │ │ │ ├── mssql_result.php │ │ │ │ └── mssql_utility.php │ │ │ ├── mysql │ │ │ │ ├── index.html │ │ │ │ ├── mysql_driver.php │ │ │ │ ├── mysql_forge.php │ │ │ │ ├── mysql_result.php │ │ │ │ └── mysql_utility.php │ │ │ ├── mysqli │ │ │ │ ├── index.html │ │ │ │ ├── mysqli_driver.php │ │ │ │ ├── mysqli_forge.php │ │ │ │ ├── mysqli_result.php │ │ │ │ └── mysqli_utility.php │ │ │ ├── oci8 │ │ │ │ ├── index.html │ │ │ │ ├── oci8_driver.php │ │ │ │ ├── oci8_forge.php │ │ │ │ ├── oci8_result.php │ │ │ │ └── oci8_utility.php │ │ │ ├── odbc │ │ │ │ ├── index.html │ │ │ │ ├── odbc_driver.php │ │ │ │ ├── odbc_forge.php │ │ │ │ ├── odbc_result.php │ │ │ │ └── odbc_utility.php │ │ │ ├── pdo │ │ │ │ ├── index.html │ │ │ │ ├── pdo_driver.php │ │ │ │ ├── pdo_forge.php │ │ │ │ ├── pdo_result.php │ │ │ │ ├── pdo_utility.php │ │ │ │ └── subdrivers │ │ │ │ │ ├── index.html │ │ │ │ │ ├── pdo_4d_driver.php │ │ │ │ │ ├── pdo_4d_forge.php │ │ │ │ │ ├── pdo_cubrid_driver.php │ │ │ │ │ ├── pdo_cubrid_forge.php │ │ │ │ │ ├── pdo_dblib_driver.php │ │ │ │ │ ├── pdo_dblib_forge.php │ │ │ │ │ ├── pdo_firebird_driver.php │ │ │ │ │ ├── pdo_firebird_forge.php │ │ │ │ │ ├── pdo_ibm_driver.php │ │ │ │ │ ├── pdo_ibm_forge.php │ │ │ │ │ ├── pdo_informix_driver.php │ │ │ │ │ ├── pdo_informix_forge.php │ │ │ │ │ ├── pdo_mysql_driver.php │ │ │ │ │ ├── pdo_mysql_forge.php │ │ │ │ │ ├── pdo_oci_driver.php │ │ │ │ │ ├── pdo_oci_forge.php │ │ │ │ │ ├── pdo_odbc_driver.php │ │ │ │ │ ├── pdo_odbc_forge.php │ │ │ │ │ ├── pdo_pgsql_driver.php │ │ │ │ │ ├── pdo_pgsql_forge.php │ │ │ │ │ ├── pdo_sqlite_driver.php │ │ │ │ │ ├── pdo_sqlite_forge.php │ │ │ │ │ ├── pdo_sqlsrv_driver.php │ │ │ │ │ └── pdo_sqlsrv_forge.php │ │ │ ├── postgre │ │ │ │ ├── index.html │ │ │ │ ├── postgre_driver.php │ │ │ │ ├── postgre_forge.php │ │ │ │ ├── postgre_result.php │ │ │ │ └── postgre_utility.php │ │ │ ├── sqlite │ │ │ │ ├── index.html │ │ │ │ ├── sqlite_driver.php │ │ │ │ ├── sqlite_forge.php │ │ │ │ ├── sqlite_result.php │ │ │ │ └── sqlite_utility.php │ │ │ ├── sqlite3 │ │ │ │ ├── index.html │ │ │ │ ├── sqlite3_driver.php │ │ │ │ ├── sqlite3_forge.php │ │ │ │ ├── sqlite3_result.php │ │ │ │ └── sqlite3_utility.php │ │ │ └── sqlsrv │ │ │ │ ├── index.html │ │ │ │ ├── sqlsrv_driver.php │ │ │ │ ├── sqlsrv_forge.php │ │ │ │ ├── sqlsrv_result.php │ │ │ │ └── sqlsrv_utility.php │ │ └── index.html │ ├── fonts │ │ ├── index.html │ │ └── texb.ttf │ ├── helpers │ │ ├── array_helper.php │ │ ├── captcha_helper.php │ │ ├── cookie_helper.php │ │ ├── date_helper.php │ │ ├── directory_helper.php │ │ ├── download_helper.php │ │ ├── email_helper.php │ │ ├── file_helper.php │ │ ├── form_helper.php │ │ ├── html_helper.php │ │ ├── index.html │ │ ├── inflector_helper.php │ │ ├── language_helper.php │ │ ├── number_helper.php │ │ ├── path_helper.php │ │ ├── security_helper.php │ │ ├── smiley_helper.php │ │ ├── string_helper.php │ │ ├── text_helper.php │ │ ├── typography_helper.php │ │ ├── url_helper.php │ │ └── xml_helper.php │ ├── index.html │ ├── language │ │ ├── english │ │ │ ├── calendar_lang.php │ │ │ ├── date_lang.php │ │ │ ├── db_lang.php │ │ │ ├── email_lang.php │ │ │ ├── form_validation_lang.php │ │ │ ├── ftp_lang.php │ │ │ ├── imglib_lang.php │ │ │ ├── index.html │ │ │ ├── migration_lang.php │ │ │ ├── number_lang.php │ │ │ ├── profiler_lang.php │ │ │ ├── unit_test_lang.php │ │ │ └── upload_lang.php │ │ └── index.html │ └── libraries │ │ ├── Cache │ │ ├── Cache.php │ │ ├── drivers │ │ │ ├── Cache_apc.php │ │ │ ├── Cache_dummy.php │ │ │ ├── Cache_file.php │ │ │ ├── Cache_memcached.php │ │ │ ├── Cache_redis.php │ │ │ ├── Cache_wincache.php │ │ │ └── index.html │ │ └── index.html │ │ ├── Calendar.php │ │ ├── Cart.php │ │ ├── Driver.php │ │ ├── Email.php │ │ ├── Encrypt.php │ │ ├── Form_validation.php │ │ ├── Ftp.php │ │ ├── Image_lib.php │ │ ├── Javascript.php │ │ ├── Migration.php │ │ ├── Pagination.php │ │ ├── Parser.php │ │ ├── Profiler.php │ │ ├── Session │ │ ├── Session.php │ │ ├── drivers │ │ │ ├── Session_cookie.php │ │ │ ├── Session_native.php │ │ │ └── index.html │ │ └── index.html │ │ ├── Table.php │ │ ├── Trackback.php │ │ ├── Typography.php │ │ ├── Unit_test.php │ │ ├── Upload.php │ │ ├── User_agent.php │ │ ├── Xmlrpc.php │ │ ├── Xmlrpcs.php │ │ ├── Zip.php │ │ ├── index.html │ │ └── javascript │ │ ├── Jquery.php │ │ └── index.html └── xtaoAuth.html └── oauth2 ├── Exception.php ├── OAuth2.php ├── Provider.php ├── Provider ├── 10086.php ├── 163.php ├── 360.php ├── Baidu.php ├── Douban.php ├── Duoshuo.php ├── Feixin.php ├── Kaixin.php ├── Qq.php ├── Renren.php ├── Sohu.php ├── Taobao.php ├── Tianyi.php ├── Tweibo.php ├── Weibo.php ├── Weixin.php └── beyond the wall │ ├── Appnet.php │ ├── Blooie.php │ ├── Facebook.php │ ├── Foursquare.php │ ├── Github.php │ ├── Google.php │ ├── Instagram.php │ ├── Mailchimp.php │ ├── Mailru.php │ ├── Paypal.php │ ├── Soundcloud.php │ ├── Vkontakte.php │ ├── Windowslive.php │ └── Yandex.php ├── Token.php ├── Token ├── Access.php └── Authorize.php └── index.html /.gitignore: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2012 Chekun and Yoozi Inc., http://www.yoozi.cn 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the “Software”), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. -------------------------------------------------------------------------------- /Oauth2.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | require APPPATH.'libraries/oauth2/OAuth2.php'; 11 | 12 | /* End of file Oauth2.php */ 13 | /* Location: ./application/libraries/Oauth2.php */ -------------------------------------------------------------------------------- /example/application/cache/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/config/hooks.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/config/memcached.php: -------------------------------------------------------------------------------- 1 | array( 39 | 'hostname' => '127.0.0.1', 40 | 'port' => '11211', 41 | 'weight' => '1', 42 | ), 43 | ); 44 | 45 | /* End of file memcached.php */ 46 | /* Location: ./application/config/memcached.php */ -------------------------------------------------------------------------------- /example/application/config/profiler.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/controllers/logout.php: -------------------------------------------------------------------------------- 1 | session->userdata('is_login') AND redirect(); 10 | } 11 | 12 | public function index() 13 | { 14 | $this->session->sess_destroy(); 15 | $this->session->set_userdata('is_login', FALSE); 16 | redirect(); 17 | } 18 | } 19 | 20 | /* End of file logout.php */ 21 | /* Location: ./application/controllers/logout.php */ -------------------------------------------------------------------------------- /example/application/controllers/sns.php: -------------------------------------------------------------------------------- 1 | session->userdata('is_login') AND redirect(); 9 | } 10 | 11 | public function session($provider = '') 12 | { 13 | $this->config->load('oauth2'); 14 | $allowed_providers = $this->config->item('oauth2'); 15 | if ( ! $provider OR ! isset($allowed_providers[$provider])) 16 | { 17 | $this->session->set_flashdata('info', '暂不支持'.$provider.'方式登录.'); 18 | redirect(); 19 | return; 20 | } 21 | $this->load->library('oauth2'); 22 | $provider = $this->oauth2->provider($provider, $allowed_providers[$provider]); 23 | $args = $this->input->get(); 24 | if ($args AND !isset($args['code'])) 25 | { 26 | $this->session->set_flashdata('info', '授权失败了,可能由于应用设置问题或者用户拒绝授权.
具体原因:
'.json_encode($args)); 27 | redirect(); 28 | return; 29 | } 30 | $code = $this->input->get('code', TRUE); 31 | if ( ! $code) 32 | { 33 | try 34 | { 35 | $provider->authorize(); 36 | } 37 | catch (OAuth2_Exception $e) 38 | { 39 | $this->session->set_flashdata('info', '操作失败
'.$e.'
'); 40 | } 41 | } 42 | else 43 | { 44 | try 45 | { 46 | $token = $provider->access($code); 47 | $sns_user = $provider->get_user_info($token); 48 | if (is_array($sns_user)) 49 | { 50 | $this->session->set_flashdata('info', '登录成功'); 51 | $this->session->set_userdata('user', $sns_user); 52 | $this->session->set_userdata('is_login', TRUE); 53 | } 54 | else 55 | { 56 | $this->session->set_flashdata('info', '获取用户信息失败'); 57 | } 58 | } 59 | catch (OAuth2_Exception $e) 60 | { 61 | $this->session->set_flashdata('info', '操作失败
'.$e.'
'); 62 | } 63 | } 64 | redirect(); 65 | } 66 | } 67 | 68 | /* End of file sns.php */ 69 | /* Location: ./application/controllers/sns.php */ -------------------------------------------------------------------------------- /example/application/controllers/welcome.php: -------------------------------------------------------------------------------- 1 | config->load('oauth2'); 9 | $data['user'] = $this->session->userdata('user'); 10 | $this->load->view('welcome_message', $data); 11 | } 12 | } 13 | 14 | /* End of file welcome.php */ 15 | /* Location: ./application/controllers/welcome.php */ -------------------------------------------------------------------------------- /example/application/core/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/helpers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/hooks/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/language/english/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/libraries/Oauth2.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | require APPPATH.'libraries/oauth2/OAuth2.php'; 11 | 12 | /* End of file Oauth2.php */ 13 | /* Location: ./application/libraries/Oauth2.php */ -------------------------------------------------------------------------------- /example/application/libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Exception.php: -------------------------------------------------------------------------------- 1 | . 7 | * @author Update to draft v10 by Edison Wong . 8 | */ 9 | class OAuth2_Exception extends Exception { 10 | 11 | /** 12 | * The result from the API server that represents the exception information. 13 | */ 14 | protected $result; 15 | 16 | /** 17 | * Make a new API Exception with the given result. 18 | * 19 | * @param $result 20 | * The result from the API server. 21 | */ 22 | public function __construct($result) 23 | { 24 | $this->result = $result; 25 | 26 | $code = isset($result['code']) ? $result['code'] : 0; 27 | 28 | if (isset($result['error'])) 29 | { 30 | // OAuth 2.0 Draft 10 style 31 | $message = $result['error']; 32 | } 33 | elseif (isset($result['message'])) 34 | { 35 | // cURL style 36 | $message = $result['message']; 37 | } 38 | else 39 | { 40 | $message = 'Unknown Error.'; 41 | } 42 | 43 | parent::__construct($message, $code); 44 | } 45 | 46 | /** 47 | * Returns the associated type for the error. This will default to 48 | * 'Exception' when a type is not available. 49 | * 50 | * @return string The type for the error. 51 | */ 52 | public function getType() 53 | { 54 | if (isset($this->result['error'])) 55 | { 56 | $message = $this->result['error']; 57 | if (is_string($message)) 58 | { 59 | // OAuth 2.0 Draft 10 style 60 | return $message; 61 | } 62 | } 63 | return 'Exception'; 64 | } 65 | 66 | /** 67 | * To make debugging easier. 68 | * 69 | * @return string The string representation of the error. 70 | */ 71 | public function __toString() 72 | { 73 | $str = $this->getType() . ': '; 74 | if ($this->code != 0) 75 | { 76 | $str .= $this->code . ': '; 77 | } 78 | return $str . $this->message; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/OAuth2.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class OAuth2 { 13 | 14 | /** 15 | * Create a new provider. 16 | * 17 | * // Load the Twitter provider 18 | * $provider = $this->oauth2->provider('twitter'); 19 | * 20 | * @param string $name provider name 21 | * @param array $options provider options 22 | * @return OAuth2_Provider 23 | */ 24 | public static function provider($name, array $options = NULL) 25 | { 26 | $name = ucfirst(strtolower($name)); 27 | 28 | include_once 'Provider/'.$name.'.php'; 29 | 30 | $class = 'OAuth2_Provider_'.$name; 31 | 32 | return new $class($options); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/10086.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_10086 extends OAuth2_Provider 11 | { 12 | public $name = '10086'; 13 | 14 | public $human = '移动微博'; 15 | 16 | public $client_id_key = 'api_key'; 17 | 18 | public $client_secret_key = 'api_secret'; 19 | 20 | public $error_key = 'error_code'; 21 | 22 | public $access_token_key = 'session_key'; 23 | 24 | public $method = 'POST'; 25 | 26 | public function url_authorize() 27 | { 28 | return 'http://oapi.weibo.10086.cn/oauth/authorize.php'; 29 | } 30 | 31 | public function url_access_token() 32 | { 33 | //oauth1.0强行转换成2.0的后果 34 | $this->params['namespace'] = 'mig'; 35 | $this->params['random'] = substr(md5(time()), 0, 16); 36 | $this->params['mig'] = md5($_GET['code'].substr($this->params['random'], -1, 12).$this->client_secret.$this->params['namespace']); 37 | return 'http:// oapi.weibo.10086.cn/oauth/token.php'; 38 | } 39 | 40 | public function get_user_info(OAuth2_Token_Access $token) 41 | { 42 | 43 | $call_id = time(); 44 | $mi_sig = md5('api_key'.$this->client_id.'call_id'.$call_id.'session_key'.$token->access_token.'v2.0'.$this->client_secret); 45 | //现获取uid 46 | $url = 'http://oapi.weibo.10086.cn/users/getloggedinuser.json?'.http_build_query(array( 47 | 'session_key' => $token->access_token, 48 | 'api_key' => $this->client_id, 49 | 'v' => '2.0', 50 | 'call_id' => $call_id, 51 | 'mi_sig' => $mi_sig 52 | )); 53 | $user = json_decode(file_get_contents($url)); 54 | 55 | if ($user->error_code > 0) 56 | { 57 | throw new OAuth2_Exception((array) $user); 58 | } 59 | 60 | $uid = $user->uid; 61 | 62 | $url = 'http://oapi.weibo.10086.cn/users/getinfo.json?'.http_build_query(array( 63 | 'session_key' => $token->access_token, 64 | 'api_key' => $this->client_id, 65 | 'v' => '2.0', 66 | 'call_id' => $call_id, 67 | 'mi_sig' => $mi_sig 68 | )); 69 | $user = json_decode(file_get_contents($url)); 70 | 71 | if ($user->error_code > 0) 72 | { 73 | throw new OAuth2_Exception((array) $user); 74 | } 75 | 76 | // Create a response from the request 77 | return array( 78 | 'via' => '10086', 79 | 'uid' => $uid, 80 | 'screen_name' => $user->screen_name, 81 | 'name' => $user->username, 82 | 'location' => '', 83 | 'description' => '', 84 | 'image' => $user->tinyurl, 85 | 'access_token' => $token->access_token, 86 | 'expire_at' => $token->expires, 87 | 'refresh_token' => $token->refresh_token 88 | ); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/163.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_163 extends OAuth2_Provider 11 | { 12 | public $name = '163'; 13 | 14 | public $human = '网易微博'; 15 | 16 | public $uid_key = 'user_id'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://api.t.163.com/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://api.t.163.com/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://api.t.163.com/users/show.json?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'user_id' => $token->uid 36 | )); 37 | $user = json_decode(file_get_contents($url)); 38 | 39 | if (array_key_exists("error", $user)) 40 | { 41 | throw new OAuth2_Exception((array) $user); 42 | } 43 | 44 | // Create a response from the request 45 | return array( 46 | 'via' => '163', 47 | 'uid' => $user->id, 48 | 'screen_name' => $user->screen_name, 49 | 'name' => $user->name, 50 | 'location' => '', 51 | 'description' => $user->description, 52 | 'image' => $user->profile_image_url, 53 | 'access_token' => $token->access_token, 54 | 'expire_at' => $token->expires, 55 | 'refresh_token' => $token->refresh_token 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/360.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_360 extends OAuth2_Provider 11 | { 12 | public $name = '360'; 13 | 14 | public $human = '360'; 15 | 16 | public $uid_key = 'id'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://openapi.360.cn/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://openapi.360.cn/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://openapi.360.cn/user/me?'.http_build_query(array( 34 | 'access_token' => $token->access_token 35 | )); 36 | $user = json_decode(file_get_contents($url)); 37 | 38 | if (array_key_exists("error", $user)) 39 | { 40 | throw new OAuth2_Exception((array) $user); 41 | } 42 | 43 | // Create a response from the request 44 | return array( 45 | 'via' => '360', 46 | 'uid' => $user->id, 47 | 'screen_name' => $user->name, 48 | 'name' => '', 49 | 'location' => '', 50 | 'description' => '', 51 | 'image' => $user->avatar, 52 | 'access_token' => $token->access_token, 53 | 'expire_at' => $token->expires, 54 | 'refresh_token' => $token->refresh_token 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Baidu.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Baidu extends OAuth2_Provider 11 | { 12 | public $name = 'baidu'; 13 | 14 | public $human = '百度'; 15 | 16 | public $uid_key = 'uid'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://openapi.baidu.com/oauth/2.0/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://openapi.baidu.com/oauth/2.0/token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'uid' => $token->uid, 36 | )); 37 | $user = json_decode(file_get_contents($url)); 38 | 39 | if (array_key_exists("error", $user)) 40 | { 41 | throw new OAuth2_Exception((array) $user); 42 | } 43 | 44 | // Create a response from the request 45 | return array( 46 | 'via' => 'baidu', 47 | 'uid' => $user->uid, 48 | 'screen_name' => $user->uname, 49 | 'name' => '', 50 | 'location' => '', 51 | 'description' => '', 52 | 'image' => 'http://tb.himg.baidu.com/sys/portraitn/item/'.$user->portrait, 53 | 'access_token' => $token->access_token, 54 | 'expire_at' => $token->expires, 55 | 'refresh_token' => $token->refresh_token 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Douban.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Douban extends OAuth2_Provider 11 | { 12 | public $name = 'douban'; 13 | 14 | public $human = '豆瓣'; 15 | 16 | public $uid_key = 'douban_user_id'; 17 | 18 | public $error_key = 'msg'; 19 | 20 | public $method = 'POST'; 21 | 22 | public function url_authorize() 23 | { 24 | return 'https://www.douban.com/service/auth2/auth'; 25 | } 26 | 27 | public function url_access_token() 28 | { 29 | return 'https://www.douban.com/service/auth2/token'; 30 | } 31 | 32 | public function get_user_info(OAuth2_Token_Access $token) 33 | { 34 | 35 | $url = 'https://api.douban.com/v2/user/'.$token->uid.'?'.http_build_query(array( 36 | 'access_token' => $token->access_token 37 | )); 38 | $user = json_decode(file_get_contents($url)); 39 | 40 | if ( ! $user OR array_key_exists('msg', $user)) 41 | { 42 | throw new OAuth2_Exception((array) $user); 43 | } 44 | 45 | // Create a response from the request 46 | return array( 47 | 'via' => 'douban', 48 | 'uid' => $user->id, 49 | 'screen_name' => $user->uid, 50 | 'name' => $user->name, 51 | 'location' => '', 52 | 'description' => '', 53 | 'image' => $user->avatar, 54 | 'access_token' => $token->access_token, 55 | 'expire_at' => $token->expires, 56 | 'refresh_token' => $token->refresh_token 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Duoshuo.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Duoshuo extends OAuth2_Provider 11 | { 12 | public $name = 'duoshuo'; 13 | 14 | public $human = '多说'; 15 | 16 | public $uid_key = 'user_id'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | throw new OAuth2_Exception(array('code' => '403', 'message' => '亲,多说的授权不是从这里进来的.')); 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'http://api.duoshuo.com/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | // Create a response from the request 33 | return array( 34 | 'via' => 'duoshuo', 35 | 'uid' => $token->uid, 36 | 'screen_name' => $token->uid, 37 | 'name' => '', 38 | 'location' => '', 39 | 'description' => '', 40 | 'image' => '', 41 | 'access_token' => $token->access_token, 42 | 'expire_at' => 0, 43 | 'refresh_token' => '' 44 | ); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Feixin.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Feixin extends OAuth2_Provider 11 | { 12 | public $name = 'feixin'; 13 | 14 | public $human = '飞信'; 15 | 16 | public $uid_key = 'userId'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://i.feixin.10086.cn/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://i.feixin.10086.cn/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'GET https://i.feixin.10086.cn/api/user.json?'.http_build_query(array( 34 | 'access_token' => $token->access_token 35 | )); 36 | $user = json_decode(file_get_contents($url)); 37 | 38 | if (array_key_exists("error", $user)) 39 | { 40 | throw new OAuth2_Exception((array) $user); 41 | } 42 | 43 | // Create a response from the request 44 | return array( 45 | 'via' => 'feixin', 46 | 'uid' => $user->userId, 47 | 'screen_name' => $user->nickname, 48 | 'name' => '', 49 | 'location' => '', 50 | 'description' => $user->introducation, 51 | 'image' => $user->portraitTiny, 52 | 'access_token' => $token->access_token, 53 | 'expire_at' => $token->expires, 54 | 'refresh_token' => $token->refresh_token 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Kaixin.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Kaixin extends OAuth2_Provider 11 | { 12 | public $name = 'kaixin'; 13 | 14 | public $human = '开心网'; 15 | 16 | public $method = 'POST'; 17 | 18 | public function url_authorize() 19 | { 20 | return 'http://api.kaixin001.com/oauth2/authorize'; 21 | } 22 | 23 | public function url_access_token() 24 | { 25 | return 'https://api.kaixin001.com/oauth2/access_token'; 26 | } 27 | 28 | public function get_user_info(OAuth2_Token_Access $token) 29 | { 30 | 31 | $url = 'https://api.kaixin001.com/users/me.json?'.http_build_query(array( 32 | 'access_token' => $token->access_token 33 | )); 34 | $user = json_decode(file_get_contents($url)); 35 | 36 | if (array_key_exists("error", $user)) 37 | { 38 | throw new OAuth2_Exception((array) $user); 39 | } 40 | 41 | // Create a response from the request 42 | return array( 43 | 'via' => 'kaixin', 44 | 'uid' => $user->uid, 45 | 'screen_name' => $user->name, 46 | 'name' => '', 47 | 'location' => '', 48 | 'description' => '', 49 | 'image' => $user->logo50, 50 | 'access_token' => $token->access_token, 51 | 'expire_at' => $token->expires, 52 | 'refresh_token' => $token->refresh_token 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Qq.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Qq extends OAuth2_Provider 11 | { 12 | public $name = 'qq'; 13 | 14 | public $human = 'QQ'; 15 | 16 | public $uid_key = 'openid'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://graph.qq.com/oauth2.0/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://graph.qq.com/oauth2.0/token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | $url = 'https://graph.qq.com/oauth2.0/me?'.http_build_query(array( 33 | 'access_token' => $token->access_token 34 | )); 35 | $response = file_get_contents($url); 36 | 37 | if (strpos($response, "callback") !== false) 38 | { 39 | $lpos = strpos($response, "("); 40 | $rpos = strrpos($response, ")"); 41 | $response = substr($response, $lpos + 1, $rpos - $lpos -1); 42 | } 43 | $me = json_decode($response); 44 | 45 | if (isset($me->error)) 46 | { 47 | throw new OAuth2_Exception((array) $me); 48 | } 49 | 50 | $url = 'https://graph.qq.com/user/get_user_info?'.http_build_query(array( 51 | 'access_token' => $token->access_token, 52 | 'openid' => $me->openid, 53 | 'oauth_consumer_key' => $this->client_id 54 | )); 55 | $response = file_get_contents($url); 56 | $user = json_decode($response); 57 | 58 | if (isset($me->error)) 59 | { 60 | throw new OAuth2_Exception((array) $user); 61 | } 62 | 63 | return array( 64 | 'via' => 'qq', 65 | 'uid' => $me->openid, 66 | 'screen_name' => $user->nickname, 67 | 'name' => '', 68 | 'location' => '', 69 | 'description' => '', 70 | 'image' => $user->figureurl, 71 | 'access_token' => $token->access_token, 72 | 'expire_at' => $token->expires, 73 | 'refresh_token' => $token->refresh_token 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Renren.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Renren extends OAuth2_Provider 11 | { 12 | public $name = 'renren'; 13 | 14 | public $human = '人人'; 15 | 16 | public $method = 'POST'; 17 | 18 | public function url_authorize() 19 | { 20 | return 'https://graph.renren.com/oauth/authorize'; 21 | } 22 | 23 | public function url_access_token() 24 | { 25 | return 'https://graph.renren.com/oauth/token'; 26 | } 27 | 28 | public function get_user_info(OAuth2_Token_Access $token) 29 | { 30 | 31 | $url = 'https://api.renren.com/restserver.do'; 32 | $params = array( 33 | 'access_token' => $token->access_token, 34 | 'format' => 'JSON', 35 | 'v' => '1.0', 36 | 'call_id' => time(), 37 | 'method' => 'users.getInfo' 38 | ); 39 | $opts = array( 40 | 'http' => array( 41 | 'method' => 'POST', 42 | 'header' => 'Content-type: application/x-www-form-urlencoded', 43 | 'content' => http_build_query($params) 44 | ) 45 | ); 46 | $_default_opts = stream_context_get_params(stream_context_get_default()); 47 | $context = stream_context_create(array_merge_recursive($_default_opts['options'], $opts)); 48 | $user = json_decode(file_get_contents($url, false, $context)); 49 | 50 | if ( ! is_array($user) OR ! isset($user[0]) OR ! ($user = $user[0]) OR array_key_exists("error_code", $user)) 51 | { 52 | throw new OAuth2_Exception((array) $user); 53 | } 54 | 55 | 56 | // Create a response from the request 57 | return array( 58 | 'via' => 'renren', 59 | 'uid' => $user->uid, 60 | 'screen_name' => $user->name, 61 | 'name' => '', 62 | 'location' => '', 63 | 'description' => '', 64 | 'image' => $user->tinyurl, 65 | 'access_token' => $token->access_token, 66 | 'expire_at' => $token->expires, 67 | 'refresh_token' => $token->refresh_token 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Sohu.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Sohu extends OAuth2_Provider 11 | { 12 | public $name = 'sohu'; 13 | 14 | public $human = '搜狐微博'; 15 | 16 | public $uid_key = 'id'; 17 | 18 | public $state_key = 'wrap_client_state'; 19 | 20 | public $method = 'POST'; 21 | 22 | public function __construct(array $options = array()) 23 | { 24 | empty($options['scope']) and $options['scope'] = 'basic'; 25 | $options['scope'] = (array) $options['scope']; 26 | parent::__construct($options); 27 | } 28 | 29 | public function url_authorize() 30 | { 31 | return 'https://api.t.sohu.com/oauth2/authorize'; 32 | } 33 | 34 | public function url_access_token() 35 | { 36 | return 'https://api.t.sohu.com/oauth2/access_token'; 37 | } 38 | 39 | public function get_user_info(OAuth2_Token_Access $token) 40 | { 41 | 42 | $url = 'http://api.t.sohu.com/users/show/id.json?'.http_build_query(array( 43 | 'access_token' => $token->access_token 44 | )); 45 | $user = json_decode(file_get_contents($url)); 46 | 47 | if (array_key_exists("error", $user)) 48 | { 49 | throw new OAuth2_Exception((array) $user); 50 | } 51 | 52 | // Create a response from the request 53 | return array( 54 | 'via' => 'sohu', 55 | 'uid' => $user->id, 56 | 'screen_name' => $user->screen_name, 57 | 'name' => $user->name, 58 | 'location' => '', 59 | 'description' => $user->description, 60 | 'image' => $user->profile_image_url, 61 | 'access_token' => $token->access_token, 62 | 'expire_at' => $token->expires, 63 | 'refresh_token' => $token->refresh_token 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Taobao.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Taobao extends OAuth2_Provider 11 | { 12 | public $name = 'taobao'; 13 | 14 | public $human = '淘宝'; 15 | 16 | public $uid_key = 'taobao_user_id'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://oauth.taobao.com/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://oauth.taobao.com/token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://eco.taobao.com/router/rest?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'method' => 'taobao.user.get', 36 | 'v' => '2.0', 37 | 'format' => 'json', 38 | 'fields' => 'user_id,uid,nick,location,avatar', 39 | )); 40 | $user = json_decode(file_get_contents($url)); 41 | 42 | if (array_key_exists('error_response', $user)) 43 | { 44 | throw new OAuth2_Exception((array) $user); 45 | } 46 | 47 | // Create a response from the request 48 | return array( 49 | 'via' => 'taobao', 50 | 'uid' => $user->user_get_response->user->user_id, 51 | 'screen_name' => $user->user_get_response->user->nick, 52 | 'name' => $user->user_get_response->user->uid, 53 | 'location' => $user->user_get_response->user->location, 54 | 'description' => '', 55 | 'image' => $user->user_get_response->user->avatar, 56 | 'access_token' => $token->access_token, 57 | 'expire_at' => $token->expires, 58 | 'refresh_token' => $token->refresh_token 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Tianyi.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Tianyi extends OAuth2_Provider 11 | { 12 | public $name = 'tianyi'; 13 | 14 | public $human = '天翼'; 15 | 16 | public $uid_key = 'p_user_id'; 17 | 18 | public $client_id_key = 'app_id'; 19 | 20 | public $client_secret_key = 'app_secret'; 21 | 22 | public $error_key = 'res_code'; 23 | 24 | public $method = 'POST'; 25 | 26 | public function url_authorize() 27 | { 28 | return 'https://oauth.api.189.cn/emp/oauth2/authorize'; 29 | } 30 | 31 | public function url_access_token() 32 | { 33 | return 'https://oauth.api.189.cn/emp/oauth2/access_token'; 34 | } 35 | 36 | public function get_user_info(OAuth2_Token_Access $token) 37 | { 38 | 39 | $url = 'http://api.189.cn/upc/vitual_identity/user_network_info?type=json&'.http_build_query(array( 40 | 'access_token' => $token->access_token, 41 | 'app_id' => $this->client_id 42 | )); 43 | $user_network_info = json_decode(file_get_contents($url)); 44 | 45 | if (array_key_exists("error", $user_network_info)) 46 | { 47 | throw new OAuth2_Exception((array) $user_network_info); 48 | } 49 | 50 | // Create a response from the request 51 | return array( 52 | 'via' => 'tianyi', 53 | 'uid' => $token->uid, 54 | 'screen_name' => $user_network_info->user_nickname, 55 | 'name' => '', 56 | 'location' => '', 57 | 'description' => $user_network_info->user_selfdesc, 58 | 'image' => '', 59 | 'access_token' => $token->access_token, 60 | 'expire_at' => $token->expires, 61 | 'refresh_token' => $token->refresh_token 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Tweibo.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Tweibo extends OAuth2_Provider 11 | { 12 | public $name = 'tweibo'; 13 | 14 | public $human = '腾讯微博'; 15 | 16 | public $uid_key = 'openid'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://open.t.qq.com/cgi-bin/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://open.t.qq.com/cgi-bin/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://open.t.qq.com/api/user/info?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'oauth_consumer_key' => $this->client_id, 36 | 'openid' => $token->uid, 37 | 'clientip' => get_instance()->input->ip_address(), 38 | 'oauth_version' => '2.a' 39 | )); 40 | $user = json_decode(file_get_contents($url)); 41 | 42 | if ($user->ret) 43 | { 44 | throw new OAuth2_Exception((array) $user); 45 | } 46 | 47 | // Create a response from the request 48 | return array( 49 | 'via' => 'tweibo', 50 | 'uid' => $user->data->openid, 51 | 'screen_name' => $user->data->nick, 52 | 'name' => $user->data->name, 53 | 'location' => '', 54 | 'description' => $user->data->introduction, 55 | 'image' => $user->data->head.'/100', 56 | 'access_token' => $token->access_token, 57 | 'expire_at' => $token->expires, 58 | 'refresh_token' => $token->refresh_token 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Weibo.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Weibo extends OAuth2_Provider 11 | { 12 | public $name = 'weibo'; 13 | 14 | public $human = '新浪微博'; 15 | 16 | public $uid_key = 'uid'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://api.weibo.com/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://api.weibo.com/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://api.weibo.com/2/users/show.json?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'uid' => $token->uid, 36 | )); 37 | $user = json_decode(file_get_contents($url)); 38 | 39 | if (array_key_exists("error", $user)) 40 | { 41 | throw new OAuth2_Exception((array) $user); 42 | } 43 | 44 | // Create a response from the request 45 | return array( 46 | 'via' => 'weibo', 47 | 'uid' => $user->id, 48 | 'screen_name' => $user->screen_name, 49 | 'name' => $user->name, 50 | 'location' => $user->location, 51 | 'description' => $user->description, 52 | 'image' => $user->profile_image_url, 53 | 'access_token' => $token->access_token, 54 | 'expire_at' => $token->expires, 55 | 'refresh_token' => $token->refresh_token 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/Weixin.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Weixin extends OAuth2_Provider 11 | { 12 | public $name = 'weixin'; 13 | 14 | public $human = '微信'; 15 | 16 | public $uid_key = 'uid'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://api.weibo.com/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://api.weibo.com/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://api.weibo.com/2/users/show.json?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'uid' => $token->uid, 36 | )); 37 | $user = json_decode(file_get_contents($url)); 38 | 39 | if (array_key_exists("error", $user)) 40 | { 41 | throw new OAuth2_Exception((array) $user); 42 | } 43 | 44 | // Create a response from the request 45 | return array( 46 | 'via' => 'weibo', 47 | 'uid' => $user->id, 48 | 'screen_name' => $user->screen_name, 49 | 'name' => $user->name, 50 | 'location' => $user->location, 51 | 'description' => $user->description, 52 | 'image' => $user->profile_image_url, 53 | 'access_token' => $token->access_token, 54 | 'expire_at' => $token->expires, 55 | 'refresh_token' => $token->refresh_token 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Appnet.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 42 | )); 43 | 44 | $user = json_decode(file_get_contents($url)); 45 | 46 | // Create a response from the request 47 | return array( 48 | 'uid' => $user->id, 49 | 'nickname' => $user->username, 50 | 'name' => $user->name 51 | ); 52 | 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Blooie.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 49 | )); 50 | 51 | $user = json_decode(file_get_contents($url)); 52 | 53 | // Create a response from the request 54 | return array( 55 | 'uid' => $user->id, 56 | 'nickname' => $user->username, 57 | 'name' => $user->name, 58 | 'first_name' => $user->first_name, 59 | 'last_name' => $user->last_name, 60 | 'email' => isset($user->email) ? $user->email : null, 61 | 'location' => isset($user->hometown->name) ? $user->hometown->name : null, 62 | 'description' => isset($user->bio) ? $user->bio : null, 63 | 'image' => 'https://graph.facebook.com/me/picture?type=normal&access_token='.$token->access_token, 64 | 'urls' => array( 65 | 'Facebook' => $user->link, 66 | ), 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Facebook.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 30 | )); 31 | 32 | $user = json_decode(file_get_contents($url)); 33 | 34 | // Create a response from the request 35 | return array( 36 | 'uid' => $user->id, 37 | 'nickname' => isset($user->username) ? $user->username : null, 38 | 'name' => $user->name, 39 | 'first_name' => $user->first_name, 40 | 'last_name' => $user->last_name, 41 | 'email' => isset($user->email) ? $user->email : null, 42 | 'location' => isset($user->hometown->name) ? $user->hometown->name : null, 43 | 'description' => isset($user->bio) ? $user->bio : null, 44 | 'image' => 'https://graph.facebook.com/me/picture?type=normal&access_token='.$token->access_token, 45 | 'urls' => array( 46 | 'Facebook' => $user->link, 47 | ), 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Foursquare.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 30 | )); 31 | 32 | $response = json_decode(file_get_contents($url)); 33 | 34 | $user = $response->response->user; 35 | 36 | // Create a response from the request 37 | return array( 38 | 'uid' => $user->id, 39 | //'nickname' => $user->login, 40 | 'name' => sprintf('%s %s', $user->firstName, $user->lastName), 41 | 'email' => $user->contact->email, 42 | 'image' => $user->photo, 43 | 'location' => $user->homeCity, 44 | ); 45 | } 46 | } -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Github.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 28 | )); 29 | 30 | $user = json_decode(file_get_contents($url)); 31 | 32 | // Create a response from the request 33 | return array( 34 | 'uid' => $user->id, 35 | 'nickname' => $user->login, 36 | 'name' => $user->name, 37 | 'email' => $user->email, 38 | 'urls' => array( 39 | 'GitHub' => 'http://github.com/'.$user->login, 40 | 'Blog' => $user->blog, 41 | ), 42 | ); 43 | } 44 | } -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Google.php: -------------------------------------------------------------------------------- 1 | 'Expected Authorization Code from '.ucfirst($this->name).' is missing')); 59 | } 60 | 61 | return parent::access($code, $options); 62 | } 63 | 64 | public function get_user_info(OAuth2_Token_Access $token) 65 | { 66 | $url = 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&'.http_build_query(array( 67 | 'access_token' => $token->access_token, 68 | )); 69 | 70 | $user = json_decode(file_get_contents($url), true); 71 | return array( 72 | 'uid' => $user['id'], 73 | 'nickname' => url_title($user['name'], '_', true), 74 | 'name' => $user['name'], 75 | 'first_name' => $user['given_name'], 76 | 'last_name' => $user['family_name'], 77 | 'email' => $user['email'], 78 | 'location' => null, 79 | 'image' => (isset($user['picture'])) ? $user['picture'] : null, 80 | 'description' => null, 81 | 'urls' => array(), 82 | ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Instagram.php: -------------------------------------------------------------------------------- 1 | user; 37 | 38 | return array( 39 | 'uid' => $user->id, 40 | 'nickname' => $user->username, 41 | 'name' => $user->full_name, 42 | 'image' => $user->profile_picture, 43 | 'urls' => array( 44 | 'website' => $user->website, 45 | ), 46 | ); 47 | } 48 | } -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Mailchimp.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Mailru.php: -------------------------------------------------------------------------------- 1 | $value) { 29 | $params .= "$key=$value"; 30 | } 31 | return md5($params . $secret_key); 32 | } 33 | 34 | public function get_user_info(OAuth2_Token_Access $token) 35 | { 36 | $request_params = array( 37 | 'app_id' => $this->client_id, 38 | 'method' => 'users.getInfo', 39 | 'uids' => $token->uid, 40 | 'access_token' => $token->access_token, 41 | 'secure' => 1 42 | ); 43 | 44 | $sig = $this->sign_server_server($request_params,$this->client_secret); 45 | $url = 'http://www.appsmail.ru/platform/api?'.http_build_query($request_params).'&sig='.$sig; 46 | 47 | $user = json_decode(file_get_contents($url)); 48 | 49 | return array( 50 | 'uid' => $user[0]->uid, 51 | 'nickname' => $user[0]->nick, 52 | 'name' => $user[0]->first_name.' '.$user[0]->last_name, 53 | 'first_name' => $user[0]->first_name, 54 | 'last_name' => $user[0]->last_name, 55 | 'email' => isset($user[0]->email) ? $user[0]->email : null, 56 | 'image' => isset($user[0]->pic_big) ? $user[0]->pic_big : null, 57 | ); 58 | } 59 | 60 | public function authorize($options = array()) 61 | { 62 | $state = md5(uniqid(rand(), TRUE)); 63 | get_instance()->session->set_userdata('state', $state); 64 | 65 | $params = array( 66 | 'client_id' => $this->client_id, 67 | 'redirect_uri' => isset($options['redirect_uri']) ? $options['redirect_uri'] : $this->redirect_uri, 68 | 'response_type' => 'code', 69 | ); 70 | 71 | redirect($this->url_authorize().'?'.http_build_query($params)); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Paypal.php: -------------------------------------------------------------------------------- 1 | $token->access_token 38 | )); 39 | 40 | $user = json_decode(file_get_contents($url),true); 41 | $user = $user['identity']; 42 | 43 | return array( 44 | 'uid' => $user['userId'], 45 | 'nickname' => url_title($user['fullName'], '_', true), 46 | 'name' => $user['fullName'], 47 | 'first_name' => $user['firstName'], 48 | 'last_name' => $user['lastName'], 49 | 'email' => $user['emails'][0], 50 | 'location' => $user->addresses[0], 51 | 'image' => null, 52 | 'description' => null, 53 | 'urls' => array( 54 | 'PayPal' => null 55 | ) 56 | ); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Soundcloud.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 33 | )); 34 | 35 | $user = json_decode(file_get_contents($url)); 36 | 37 | // Create a response from the request 38 | return array( 39 | 'uid' => $user->id, 40 | 'nickname' => $user->username, 41 | 'name' => $user->full_name, 42 | 'location' => $user->country.' ,'.$user->country, 43 | 'description' => $user->description, 44 | 'image' => $user->avatar_url, 45 | 'urls' => array( 46 | 'MySpace' => $user->myspace_name, 47 | 'Website' => $user->website, 48 | ), 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Vkontakte.php: -------------------------------------------------------------------------------- 1 | $token->uid, 30 | 'fields' => implode(",",$scope), 31 | 'access_token' => $token->access_token, 32 | )); 33 | 34 | $user = json_decode(file_get_contents($url))->response; 35 | 36 | if(sizeof($user)==0) 37 | return null; 38 | else 39 | $user = $user[0]; 40 | 41 | return array( 42 | 'uid' => $user->uid, 43 | 'nickname' => isset($user->nickname) ? $user->nickname : null, 44 | 'name' => isset($user->name) ? $user->name : null, 45 | 'first_name' => isset($user->first_name) ? $user->first_name : null, 46 | 'last_name' => isset($user->last_name) ? $user->last_name : null, 47 | 'email' => null, 48 | 'location' => null, 49 | 'description' => null, 50 | 'image' => isset($user->photo_big) ? $user->photo_big : null, 51 | 'urls' => array(), 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Provider/beyond the wall/Windowslive.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 44 | )); 45 | 46 | // perform network request 47 | $user = json_decode(file_get_contents($url)); 48 | 49 | // create a response from the request and return it 50 | return array( 51 | 'uid' => $user->id, 52 | 'name' => $user->name, 53 | 'nickname' => url_title($user->name, '_', true), 54 | // 'location' => $user[''], # scope wl.postal_addresses is required 55 | # but won't be implemented by default 56 | 'locale' => $user->locale, 57 | 'urls' => array('Windows Live' => $user->link), 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Token.php: -------------------------------------------------------------------------------- 1 | secret; 38 | * 39 | * @param string $key variable name 40 | * @return mixed 41 | */ 42 | public function __get($key) 43 | { 44 | return $this->$key; 45 | } 46 | 47 | /** 48 | * Return a boolean if the property is set 49 | * 50 | * // Get the token secret 51 | * if ($token->secret) exit('YAY SECRET'); 52 | * 53 | * @param string $key variable name 54 | * @return bool 55 | */ 56 | public function __isset($key) 57 | { 58 | return isset($this->$key); 59 | } 60 | 61 | } // End Token 62 | -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Token/Access.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | 18 | class OAuth2_Token_Access extends OAuth2_Token 19 | { 20 | /** 21 | * @var string access_token 22 | */ 23 | protected $access_token; 24 | 25 | /** 26 | * @var int expires 27 | */ 28 | protected $expires; 29 | 30 | /** 31 | * @var string refresh_token 32 | */ 33 | protected $refresh_token; 34 | 35 | /** 36 | * @var string uid 37 | */ 38 | protected $uid; 39 | 40 | /** 41 | * Sets the token, expiry, etc values. 42 | * 43 | * @param array $options token options 44 | * 45 | * @throws Exception if required options are missing 46 | */ 47 | public function __construct(array $options = null) 48 | { 49 | if ( ! isset($options[$options['access_token_key']])) 50 | { 51 | throw new Exception('Required option not passed: access_token'.PHP_EOL.print_r($options, true)); 52 | } 53 | 54 | // if ( ! isset($options['expires_in']) and ! isset($options['expires'])) 55 | // { 56 | // throw new Exception('We do not know when this access_token will expire'); 57 | // } 58 | 59 | $this->access_token = $options[$options['access_token_key']]; 60 | 61 | isset($options[$options['uid_key']]) and $this->uid = $options[$options['uid_key']]; 62 | 63 | //Mailru uses x_mailru_vid instead of uid 64 | isset($options['x_mailru_vid']) and $this->uid = $options['x_mailru_vid']; 65 | 66 | // We need to know when the token expires, add num. seconds to current time 67 | isset($options['expires_in']) and $this->expires = time() + ((int) $options['expires_in']); 68 | 69 | // Facebook is just being a spec ignoring jerk 70 | isset($options['expires']) and $this->expires = time() + ((int) $options['expires']); 71 | 72 | // Grab a refresh token so we can update access tokens when they expires 73 | isset($options['refresh_token']) and $this->refresh_token = $options['refresh_token']; 74 | } 75 | 76 | /** 77 | * Returns the token key. 78 | * 79 | * @return string 80 | */ 81 | public function __toString() 82 | { 83 | return (string) $this->access_token; 84 | } 85 | 86 | } // End OAuth2_Token_Access -------------------------------------------------------------------------------- /example/application/libraries/oauth2/Token/Authorize.php: -------------------------------------------------------------------------------- 1 | code = $options['code']; 42 | $this->redirect_uri = $options['redirect_uri']; 43 | } 44 | 45 | /** 46 | * Returns the token key. 47 | * 48 | * @return string 49 | */ 50 | public function __toString() 51 | { 52 | return (string) $this->code; 53 | } 54 | 55 | } // End OAuth2_Token_Access -------------------------------------------------------------------------------- /example/application/libraries/oauth2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/logs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/models/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/third_party/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/views/errors/error_404.php: -------------------------------------------------------------------------------- 1 | 29 | 30 | 31 | 32 | 404 Page Not Found 33 | 85 | 86 | 87 |
88 |

89 | 90 |
91 | 92 | -------------------------------------------------------------------------------- /example/application/views/errors/error_db.php: -------------------------------------------------------------------------------- 1 | 29 | 30 | 31 | 32 | Database Error 33 | 85 | 86 | 87 |
88 |

89 | 90 |
91 | 92 | -------------------------------------------------------------------------------- /example/application/views/errors/error_general.php: -------------------------------------------------------------------------------- 1 | 29 | 30 | 31 | 32 | Error 33 | 85 | 86 | 87 |
88 |

89 | 90 |
91 | 92 | -------------------------------------------------------------------------------- /example/application/views/errors/error_php.php: -------------------------------------------------------------------------------- 1 | 29 | 30 |
31 | 32 |

A PHP Error was encountered

33 | 34 |

Severity:

35 |

Message:

36 |

Filename:

37 |

Line Number:

38 | 39 | 40 | 41 |

Backtrace:

42 | 43 | 44 | 46 | 47 |

48 | File:
49 | Line:
50 | Function: 51 |

52 | 53 | 54 | 55 |

56 | 57 | 58 | 59 |
-------------------------------------------------------------------------------- /example/application/views/errors/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/application/views/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/bd_dc241d3dd58dc598.txt: -------------------------------------------------------------------------------- 1 | BAIDU -------------------------------------------------------------------------------- /example/config.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: oauth24codeignier 3 | version: 1 4 | handle: 5 | - rewrite: if(!is_dir() && !is_file() && path~"^(.*)$") goto "index.php/$1" -------------------------------------------------------------------------------- /example/system/core/Controller.php: -------------------------------------------------------------------------------- 1 | $class) 63 | { 64 | $this->$var =& load_class($class); 65 | } 66 | 67 | $this->load =& load_class('Loader', 'core'); 68 | $this->load->initialize(); 69 | log_message('debug', 'Controller Class Initialized'); 70 | } 71 | 72 | // -------------------------------------------------------------------- 73 | 74 | /** 75 | * Get the CI singleton 76 | * 77 | * @static 78 | * @return object 79 | */ 80 | public static function &get_instance() 81 | { 82 | return self::$instance; 83 | } 84 | 85 | } 86 | 87 | /* End of file Controller.php */ 88 | /* Location: ./system/core/Controller.php */ -------------------------------------------------------------------------------- /example/system/core/Model.php: -------------------------------------------------------------------------------- 1 | $key; 64 | } 65 | 66 | } 67 | 68 | /* End of file Model.php */ 69 | /* Location: ./system/core/Model.php */ -------------------------------------------------------------------------------- /example/system/core/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/cubrid/cubrid_utility.php: -------------------------------------------------------------------------------- 1 | db->data_cache['db_names'])) 46 | { 47 | return $this->db->data_cache['db_names']; 48 | } 49 | 50 | return $this->db->data_cache['db_names'] = cubrid_list_dbs($this->db->conn_id); 51 | } 52 | 53 | // -------------------------------------------------------------------- 54 | 55 | /** 56 | * CUBRID Export 57 | * 58 | * @param array Preferences 59 | * @return mixed 60 | */ 61 | protected function _backup($params = array()) 62 | { 63 | // No SQL based support in CUBRID as of version 8.4.0. Database or 64 | // table backup can be performed using CUBRID Manager 65 | // database administration tool. 66 | return $this->db->display_error('db_unsupported_feature'); 67 | } 68 | } 69 | 70 | /* End of file cubrid_utility.php */ 71 | /* Location: ./system/database/drivers/cubrid/cubrid_utility.php */ -------------------------------------------------------------------------------- /example/system/database/drivers/cubrid/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/ibase/ibase_utility.php: -------------------------------------------------------------------------------- 1 | db->hostname, $this->db->username, $this->db->password)) 47 | { 48 | $res = ibase_backup($service, $this->db->database, $filename.'.fbk'); 49 | 50 | // Close the service connection 51 | ibase_service_detach($service); 52 | return $res; 53 | } 54 | 55 | return FALSE; 56 | } 57 | 58 | } 59 | 60 | /* End of file ibase_utility.php */ 61 | /* Location: ./system/database/drivers/ibase/ibase_utility.php */ -------------------------------------------------------------------------------- /example/system/database/drivers/ibase/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/mssql/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/mssql/mssql_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 62 | } 63 | 64 | } 65 | 66 | /* End of file mssql_utility.php */ 67 | /* Location: ./system/database/drivers/mssql/mssql_utility.php */ -------------------------------------------------------------------------------- /example/system/database/drivers/mysql/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/mysqli/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/oci8/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/oci8/oci8_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 55 | } 56 | 57 | } 58 | 59 | /* End of file oci8_utility.php */ 60 | /* Location: ./system/database/drivers/oci8/oci8_utility.php */ -------------------------------------------------------------------------------- /example/system/database/drivers/odbc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/odbc/odbc_forge.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 48 | } 49 | 50 | } 51 | 52 | /* End of file odbc_utility.php */ 53 | /* Location: ./system/database/drivers/odbc/odbc_utility.php */ -------------------------------------------------------------------------------- /example/system/database/drivers/pdo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/pdo/pdo_forge.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 48 | } 49 | 50 | } 51 | 52 | /* End of file pdo_utility.php */ 53 | /* Location: ./system/database/drivers/pdo/pdo_utility.php */ -------------------------------------------------------------------------------- /example/system/database/drivers/pdo/subdrivers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/pdo/subdrivers/pdo_odbc_forge.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/postgre/postgre_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 64 | } 65 | } 66 | 67 | /* End of file postgre_utility.php */ 68 | /* Location: ./system/database/drivers/postgre/postgre_utility.php */ -------------------------------------------------------------------------------- /example/system/database/drivers/sqlite/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/sqlite/sqlite_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 48 | } 49 | 50 | } 51 | 52 | /* End of file sqlite_utility.php */ 53 | /* Location: ./system/database/drivers/sqlite/sqlite_utility.php */ -------------------------------------------------------------------------------- /example/system/database/drivers/sqlite3/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/sqlite3/sqlite3_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 48 | } 49 | 50 | } 51 | 52 | /* End of file sqlite3_utility.php */ 53 | /* Location: ./system/database/drivers/sqlite3/sqlite3_utility.php */ -------------------------------------------------------------------------------- /example/system/database/drivers/sqlsrv/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/database/drivers/sqlsrv/sqlsrv_utility.php: -------------------------------------------------------------------------------- 1 | db->display_error('db_unsupported_feature'); 64 | } 65 | 66 | } 67 | 68 | /* End of file sqlsrv_utility.php */ 69 | /* Location: ./system/database/drivers/sqlsrv/sqlsrv_utility.php */ -------------------------------------------------------------------------------- /example/system/database/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/fonts/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/fonts/texb.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ronaldtech051/CodeIgniter-Oauth2-SocialAuth/43316fbc6b2c4d0decaebc71170052ce60d673db/example/system/fonts/texb.ttf -------------------------------------------------------------------------------- /example/system/helpers/directory_helper.php: -------------------------------------------------------------------------------- 1 | 0) && @is_dir($source_dir.$file)) 75 | { 76 | $filedata[$file] = directory_map($source_dir.$file, $new_depth, $hidden); 77 | } 78 | else 79 | { 80 | $filedata[] = $file; 81 | } 82 | } 83 | 84 | closedir($fp); 85 | return $filedata; 86 | } 87 | 88 | return FALSE; 89 | } 90 | } 91 | 92 | /* End of file directory_helper.php */ 93 | /* Location: ./system/helpers/directory_helper.php */ -------------------------------------------------------------------------------- /example/system/helpers/email_helper.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/helpers/language_helper.php: -------------------------------------------------------------------------------- 1 | lang->line($line); 57 | 58 | if ($for !== '') 59 | { 60 | $line = ''; 61 | } 62 | 63 | return $line; 64 | } 65 | } 66 | 67 | /* End of file language_helper.php */ 68 | /* Location: ./system/helpers/language_helper.php */ -------------------------------------------------------------------------------- /example/system/helpers/number_helper.php: -------------------------------------------------------------------------------- 1 | lang->load('number'); 54 | 55 | if ($num >= 1000000000000) 56 | { 57 | $num = round($num / 1099511627776, $precision); 58 | $unit = $CI->lang->line('terabyte_abbr'); 59 | } 60 | elseif ($num >= 1000000000) 61 | { 62 | $num = round($num / 1073741824, $precision); 63 | $unit = $CI->lang->line('gigabyte_abbr'); 64 | } 65 | elseif ($num >= 1000000) 66 | { 67 | $num = round($num / 1048576, $precision); 68 | $unit = $CI->lang->line('megabyte_abbr'); 69 | } 70 | elseif ($num >= 1000) 71 | { 72 | $num = round($num / 1024, $precision); 73 | $unit = $CI->lang->line('kilobyte_abbr'); 74 | } 75 | else 76 | { 77 | $unit = $CI->lang->line('bytes'); 78 | return number_format($num).' '.$unit; 79 | } 80 | 81 | return number_format($num, $precision).' '.$unit; 82 | } 83 | } 84 | 85 | /* End of file number_helper.php */ 86 | /* Location: ./system/helpers/number_helper.php */ -------------------------------------------------------------------------------- /example/system/helpers/path_helper.php: -------------------------------------------------------------------------------- 1 | load->library('typography'); 53 | return $CI->typography->nl2br_except_pre($str); 54 | } 55 | } 56 | 57 | // ------------------------------------------------------------------------ 58 | 59 | if ( ! function_exists('auto_typography')) 60 | { 61 | /** 62 | * Auto Typography Wrapper Function 63 | * 64 | * @param string $str 65 | * @param bool $reduce_linebreaks = FALSE whether to reduce multiple instances of double newlines to two 66 | * @return string 67 | */ 68 | function auto_typography($str, $reduce_linebreaks = FALSE) 69 | { 70 | $CI =& get_instance(); 71 | $CI->load->library('typography'); 72 | return $CI->typography->auto_typography($str, $reduce_linebreaks); 73 | } 74 | } 75 | 76 | // -------------------------------------------------------------------- 77 | 78 | if ( ! function_exists('entity_decode')) 79 | { 80 | /** 81 | * HTML Entities Decode 82 | * 83 | * This function is a replacement for html_entity_decode() 84 | * 85 | * @param string 86 | * @param string 87 | * @return string 88 | */ 89 | function entity_decode($str, $charset = NULL) 90 | { 91 | global $SEC; 92 | return $SEC->entity_decode($str, $charset); 93 | } 94 | } 95 | 96 | /* End of file typography_helper.php */ 97 | /* Location: ./system/helpers/typography_helper.php */ -------------------------------------------------------------------------------- /example/system/helpers/xml_helper.php: -------------------------------------------------------------------------------- 1 | ', '"', "'", '-'), 64 | array('&', '<', '>', '"', ''', '-'), 65 | $str); 66 | 67 | // Decode the temp markers back to entities 68 | $str = preg_replace('/'.$temp.'(\d+);/', '&#\\1;', $str); 69 | 70 | if ($protect_all === TRUE) 71 | { 72 | return preg_replace('/'.$temp.'(\w+);/', '&\\1;', $str); 73 | } 74 | 75 | return $str; 76 | } 77 | } 78 | 79 | /* End of file xml_helper.php */ 80 | /* Location: ./system/helpers/xml_helper.php */ -------------------------------------------------------------------------------- /example/system/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/language/english/calendar_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/language/english/migration_lang.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/libraries/Cache/drivers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/libraries/Cache/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/libraries/Session/drivers/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/libraries/Session/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/libraries/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/system/libraries/javascript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | -------------------------------------------------------------------------------- /example/xtaoAuth.html: -------------------------------------------------------------------------------- 1 | 2 | BcLRzGdZfe9D2XaIk52d8g== -------------------------------------------------------------------------------- /oauth2/Exception.php: -------------------------------------------------------------------------------- 1 | . 7 | * @author Update to draft v10 by Edison Wong . 8 | */ 9 | class OAuth2_Exception extends Exception { 10 | 11 | /** 12 | * The result from the API server that represents the exception information. 13 | */ 14 | protected $result; 15 | 16 | /** 17 | * Make a new API Exception with the given result. 18 | * 19 | * @param $result 20 | * The result from the API server. 21 | */ 22 | public function __construct($result) 23 | { 24 | $this->result = $result; 25 | 26 | $code = isset($result['code']) ? $result['code'] : 0; 27 | 28 | if (isset($result['error'])) 29 | { 30 | // OAuth 2.0 Draft 10 style 31 | $message = $result['error']; 32 | } 33 | elseif (isset($result['message'])) 34 | { 35 | // cURL style 36 | $message = $result['message']; 37 | } 38 | else 39 | { 40 | $message = 'Unknown Error.'; 41 | } 42 | 43 | parent::__construct($message, $code); 44 | } 45 | 46 | /** 47 | * Returns the associated type for the error. This will default to 48 | * 'Exception' when a type is not available. 49 | * 50 | * @return string The type for the error. 51 | */ 52 | public function getType() 53 | { 54 | if (isset($this->result['error'])) 55 | { 56 | $message = $this->result['error']; 57 | if (is_string($message)) 58 | { 59 | // OAuth 2.0 Draft 10 style 60 | return $message; 61 | } 62 | } 63 | return 'Exception'; 64 | } 65 | 66 | /** 67 | * To make debugging easier. 68 | * 69 | * @return string The string representation of the error. 70 | */ 71 | public function __toString() 72 | { 73 | $str = $this->getType() . ': '; 74 | if ($this->code != 0) 75 | { 76 | $str .= $this->code . ': '; 77 | } 78 | return $str . $this->message; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /oauth2/OAuth2.php: -------------------------------------------------------------------------------- 1 | 11 | */ 12 | class OAuth2 { 13 | 14 | /** 15 | * Create a new provider. 16 | * 17 | * // Load the Twitter provider 18 | * $provider = $this->oauth2->provider('twitter'); 19 | * 20 | * @param string $name provider name 21 | * @param array $options provider options 22 | * @return OAuth2_Provider 23 | */ 24 | public static function provider($name, array $options = NULL) 25 | { 26 | $name = ucfirst(strtolower($name)); 27 | 28 | include_once 'Provider/'.$name.'.php'; 29 | 30 | $class = 'OAuth2_Provider_'.$name; 31 | 32 | return new $class($options); 33 | } 34 | 35 | } -------------------------------------------------------------------------------- /oauth2/Provider/163.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_163 extends OAuth2_Provider 11 | { 12 | public $name = '163'; 13 | 14 | public $human = '网易微博'; 15 | 16 | public $uid_key = 'user_id'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://api.t.163.com/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://api.t.163.com/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://api.t.163.com/users/show.json?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'user_id' => $token->uid 36 | )); 37 | $user = json_decode(file_get_contents($url)); 38 | 39 | if (array_key_exists("error", $user)) 40 | { 41 | throw new OAuth2_Exception((array) $user); 42 | } 43 | 44 | // Create a response from the request 45 | return array( 46 | 'via' => '163', 47 | 'uid' => $user->id, 48 | 'screen_name' => $user->screen_name, 49 | 'name' => $user->name, 50 | 'location' => '', 51 | 'description' => $user->description, 52 | 'image' => $user->profile_image_url, 53 | 'access_token' => $token->access_token, 54 | 'expire_at' => $token->expires, 55 | 'refresh_token' => $token->refresh_token 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /oauth2/Provider/360.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_360 extends OAuth2_Provider 11 | { 12 | public $name = '360'; 13 | 14 | public $human = '360'; 15 | 16 | public $uid_key = 'id'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://openapi.360.cn/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://openapi.360.cn/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://openapi.360.cn/user/me?'.http_build_query(array( 34 | 'access_token' => $token->access_token 35 | )); 36 | $user = json_decode(file_get_contents($url)); 37 | 38 | if (array_key_exists("error", $user)) 39 | { 40 | throw new OAuth2_Exception((array) $user); 41 | } 42 | 43 | // Create a response from the request 44 | return array( 45 | 'via' => '360', 46 | 'uid' => $user->id, 47 | 'screen_name' => $user->name, 48 | 'name' => '', 49 | 'location' => '', 50 | 'description' => '', 51 | 'image' => $user->avatar, 52 | 'access_token' => $token->access_token, 53 | 'expire_at' => $token->expires, 54 | 'refresh_token' => $token->refresh_token 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /oauth2/Provider/Baidu.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Baidu extends OAuth2_Provider 11 | { 12 | public $name = 'baidu'; 13 | 14 | public $human = '百度'; 15 | 16 | public $uid_key = 'uid'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://openapi.baidu.com/oauth/2.0/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://openapi.baidu.com/oauth/2.0/token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://openapi.baidu.com/rest/2.0/passport/users/getLoggedInUser?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'uid' => $token->uid, 36 | )); 37 | $user = json_decode(file_get_contents($url)); 38 | 39 | if (array_key_exists("error", $user)) 40 | { 41 | throw new OAuth2_Exception((array) $user); 42 | } 43 | 44 | // Create a response from the request 45 | return array( 46 | 'via' => 'baidu', 47 | 'uid' => $user->uid, 48 | 'screen_name' => $user->uname, 49 | 'name' => '', 50 | 'location' => '', 51 | 'description' => '', 52 | 'image' => 'http://tb.himg.baidu.com/sys/portraitn/item/'.$user->portrait, 53 | 'access_token' => $token->access_token, 54 | 'expire_at' => $token->expires, 55 | 'refresh_token' => $token->refresh_token 56 | ); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /oauth2/Provider/Douban.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Douban extends OAuth2_Provider 11 | { 12 | public $name = 'douban'; 13 | 14 | public $human = '豆瓣'; 15 | 16 | public $uid_key = 'douban_user_id'; 17 | 18 | public $error_key = 'msg'; 19 | 20 | public $method = 'POST'; 21 | 22 | public function url_authorize() 23 | { 24 | return 'https://www.douban.com/service/auth2/auth'; 25 | } 26 | 27 | public function url_access_token() 28 | { 29 | return 'https://www.douban.com/service/auth2/token'; 30 | } 31 | 32 | public function get_user_info(OAuth2_Token_Access $token) 33 | { 34 | 35 | $url = 'https://api.douban.com/v2/user/'.$token->uid.'?'.http_build_query(array( 36 | 'access_token' => $token->access_token 37 | )); 38 | $user = json_decode(file_get_contents($url)); 39 | 40 | if ( ! $user OR array_key_exists('msg', $user)) 41 | { 42 | throw new OAuth2_Exception((array) $user); 43 | } 44 | 45 | // Create a response from the request 46 | return array( 47 | 'via' => 'douban', 48 | 'uid' => $user->id, 49 | 'screen_name' => $user->uid, 50 | 'name' => $user->name, 51 | 'location' => '', 52 | 'description' => '', 53 | 'image' => $user->avatar, 54 | 'access_token' => $token->access_token, 55 | 'expire_at' => $token->expires, 56 | 'refresh_token' => $token->refresh_token 57 | ); 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /oauth2/Provider/Duoshuo.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Duoshuo extends OAuth2_Provider 11 | { 12 | public $name = 'duoshuo'; 13 | 14 | public $human = '多说'; 15 | 16 | public $uid_key = 'user_id'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | throw new OAuth2_Exception(array('code' => '403', 'message' => '亲,多说的授权不是从这里进来的.')); 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'http://api.duoshuo.com/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | return array( 33 | 'via' => 'duoshuo', 34 | 'uid' => $token->uid, 35 | 'screen_name' => $token->uid, 36 | 'name' => '', 37 | 'location' => '', 38 | 'description' => '', 39 | 'image' => '', 40 | 'access_token' => $token->access_token, 41 | 'expire_at' => 0, 42 | 'refresh_token' => '' 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /oauth2/Provider/Feixin.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Feixin extends OAuth2_Provider 11 | { 12 | public $name = 'feixin'; 13 | 14 | public $human = '飞信'; 15 | 16 | public $uid_key = 'userId'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://i.feixin.10086.cn/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://i.feixin.10086.cn/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'GET https://i.feixin.10086.cn/api/user.json?'.http_build_query(array( 34 | 'access_token' => $token->access_token 35 | )); 36 | $user = json_decode(file_get_contents($url)); 37 | 38 | if (array_key_exists("error", $user)) 39 | { 40 | throw new OAuth2_Exception((array) $user); 41 | } 42 | 43 | // Create a response from the request 44 | return array( 45 | 'via' => 'feixin', 46 | 'uid' => $user->userId, 47 | 'screen_name' => $user->nickname, 48 | 'name' => '', 49 | 'location' => '', 50 | 'description' => $user->introducation, 51 | 'image' => $user->portraitTiny, 52 | 'access_token' => $token->access_token, 53 | 'expire_at' => $token->expires, 54 | 'refresh_token' => $token->refresh_token 55 | ); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /oauth2/Provider/Kaixin.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Kaixin extends OAuth2_Provider 11 | { 12 | public $name = 'kaixin'; 13 | 14 | public $human = '开心网'; 15 | 16 | public $method = 'POST'; 17 | 18 | public function url_authorize() 19 | { 20 | return 'http://api.kaixin001.com/oauth2/authorize'; 21 | } 22 | 23 | public function url_access_token() 24 | { 25 | return 'https://api.kaixin001.com/oauth2/access_token'; 26 | } 27 | 28 | public function get_user_info(OAuth2_Token_Access $token) 29 | { 30 | 31 | $url = 'https://api.kaixin001.com/users/me.json?'.http_build_query(array( 32 | 'access_token' => $token->access_token 33 | )); 34 | $user = json_decode(file_get_contents($url)); 35 | 36 | if (array_key_exists("error", $user)) 37 | { 38 | throw new OAuth2_Exception((array) $user); 39 | } 40 | 41 | return array( 42 | 'via' => 'kaixin', 43 | 'uid' => $user->uid, 44 | 'screen_name' => $user->name, 45 | 'name' => '', 46 | 'location' => '', 47 | 'description' => '', 48 | 'image' => $user->logo50, 49 | 'access_token' => $token->access_token, 50 | 'expire_at' => $token->expires, 51 | 'refresh_token' => $token->refresh_token 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /oauth2/Provider/Qq.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Qq extends OAuth2_Provider 11 | { 12 | public $name = 'qq'; 13 | 14 | public $human = 'QQ'; 15 | 16 | public $uid_key = 'openid'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://graph.qq.com/oauth2.0/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://graph.qq.com/oauth2.0/token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | $url = 'https://graph.qq.com/oauth2.0/me?'.http_build_query(array( 33 | 'access_token' => $token->access_token 34 | )); 35 | $response = file_get_contents($url); 36 | 37 | if (strpos($response, "callback") !== false) 38 | { 39 | $lpos = strpos($response, "("); 40 | $rpos = strrpos($response, ")"); 41 | $response = substr($response, $lpos + 1, $rpos - $lpos -1); 42 | } 43 | $me = json_decode($response); 44 | 45 | if (isset($me->error)) 46 | { 47 | throw new OAuth2_Exception((array) $me); 48 | } 49 | 50 | $url = 'https://graph.qq.com/user/get_user_info?'.http_build_query(array( 51 | 'access_token' => $token->access_token, 52 | 'openid' => $me->openid, 53 | 'oauth_consumer_key' => $this->client_id 54 | )); 55 | $response = file_get_contents($url); 56 | $user = json_decode($response); 57 | 58 | if (isset($me->error)) 59 | { 60 | throw new OAuth2_Exception((array) $user); 61 | } 62 | 63 | return array( 64 | 'via' => 'qq', 65 | 'uid' => $me->openid, 66 | 'screen_name' => $user->nickname, 67 | 'name' => '', 68 | 'location' => '', 69 | 'description' => '', 70 | 'image' => $user->figureurl, 71 | 'access_token' => $token->access_token, 72 | 'expire_at' => $token->expires, 73 | 'refresh_token' => $token->refresh_token 74 | ); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /oauth2/Provider/Renren.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Renren extends OAuth2_Provider 11 | { 12 | public $name = 'renren'; 13 | 14 | public $human = '人人'; 15 | 16 | public $method = 'POST'; 17 | 18 | public function url_authorize() 19 | { 20 | return 'https://graph.renren.com/oauth/authorize'; 21 | } 22 | 23 | public function url_access_token() 24 | { 25 | return 'https://graph.renren.com/oauth/token'; 26 | } 27 | 28 | public function get_user_info(OAuth2_Token_Access $token) 29 | { 30 | 31 | $url = 'https://api.renren.com/restserver.do'; 32 | $params = array( 33 | 'access_token' => $token->access_token, 34 | 'format' => 'JSON', 35 | 'v' => '1.0', 36 | 'call_id' => time(), 37 | 'method' => 'users.getInfo' 38 | ); 39 | $opts = array( 40 | 'http' => array( 41 | 'method' => 'POST', 42 | 'header' => 'Content-type: application/x-www-form-urlencoded', 43 | 'content' => http_build_query($params) 44 | ) 45 | ); 46 | $_default_opts = stream_context_get_params(stream_context_get_default()); 47 | $context = stream_context_create(array_merge_recursive($_default_opts['options'], $opts)); 48 | $user = json_decode(file_get_contents($url, false, $context)); 49 | 50 | if ( ! is_array($user) OR ! isset($user[0]) OR ! ($user = $user[0]) OR array_key_exists("error_code", $user)) 51 | { 52 | throw new OAuth2_Exception((array) $user); 53 | } 54 | 55 | 56 | // Create a response from the request 57 | return array( 58 | 'via' => 'renren', 59 | 'uid' => $user->uid, 60 | 'screen_name' => $user->name, 61 | 'name' => '', 62 | 'location' => '', 63 | 'description' => '', 64 | 'image' => $user->tinyurl, 65 | 'access_token' => $token->access_token, 66 | 'expire_at' => $token->expires, 67 | 'refresh_token' => $token->refresh_token 68 | ); 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /oauth2/Provider/Sohu.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Sohu extends OAuth2_Provider 11 | { 12 | public $name = 'sohu'; 13 | 14 | public $human = '搜狐微博'; 15 | 16 | public $uid_key = 'id'; 17 | 18 | public $state_key = 'wrap_client_state'; 19 | 20 | public $method = 'POST'; 21 | 22 | public function __construct(array $options = array()) 23 | { 24 | empty($options['scope']) and $options['scope'] = 'basic'; 25 | $options['scope'] = (array) $options['scope']; 26 | parent::__construct($options); 27 | } 28 | 29 | public function url_authorize() 30 | { 31 | return 'https://api.t.sohu.com/oauth2/authorize'; 32 | } 33 | 34 | public function url_access_token() 35 | { 36 | return 'https://api.t.sohu.com/oauth2/access_token'; 37 | } 38 | 39 | public function get_user_info(OAuth2_Token_Access $token) 40 | { 41 | 42 | $url = 'http://api.t.sohu.com/users/show/id.json?'.http_build_query(array( 43 | 'access_token' => $token->access_token 44 | )); 45 | $user = json_decode(file_get_contents($url)); 46 | 47 | if (array_key_exists("error", $user)) 48 | { 49 | throw new OAuth2_Exception((array) $user); 50 | } 51 | 52 | // Create a response from the request 53 | return array( 54 | 'via' => 'sohu', 55 | 'uid' => $user->id, 56 | 'screen_name' => $user->screen_name, 57 | 'name' => $user->name, 58 | 'location' => '', 59 | 'description' => $user->description, 60 | 'image' => $user->profile_image_url, 61 | 'access_token' => $token->access_token, 62 | 'expire_at' => $token->expires, 63 | 'refresh_token' => $token->refresh_token 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /oauth2/Provider/Taobao.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Taobao extends OAuth2_Provider 11 | { 12 | public $name = 'taobao'; 13 | 14 | public $human = '淘宝'; 15 | 16 | public $uid_key = 'taobao_user_id'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://oauth.taobao.com/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://oauth.taobao.com/token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://eco.taobao.com/router/rest?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'method' => 'taobao.user.get', 36 | 'v' => '2.0', 37 | 'format' => 'json', 38 | 'fields' => 'user_id,uid,nick,location,avatar', 39 | )); 40 | $user = json_decode(file_get_contents($url)); 41 | 42 | if (array_key_exists('error_response', $user)) 43 | { 44 | throw new OAuth2_Exception((array) $user); 45 | } 46 | 47 | // Create a response from the request 48 | return array( 49 | 'via' => 'taobao', 50 | 'uid' => $user->user_get_response->user->user_id, 51 | 'screen_name' => $user->user_get_response->user->nick, 52 | 'name' => $user->user_get_response->user->uid, 53 | 'location' => $user->user_get_response->user->location, 54 | 'description' => '', 55 | 'image' => $user->user_get_response->user->avatar, 56 | 'access_token' => $token->access_token, 57 | 'expire_at' => $token->expires, 58 | 'refresh_token' => $token->refresh_token 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /oauth2/Provider/Tianyi.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Tianyi extends OAuth2_Provider 11 | { 12 | public $name = 'tianyi'; 13 | 14 | public $human = '天翼'; 15 | 16 | public $uid_key = 'p_user_id'; 17 | 18 | public $client_id_key = 'app_id'; 19 | 20 | public $client_secret_key = 'app_secret'; 21 | 22 | public $error_key = 'res_code'; 23 | 24 | public $method = 'POST'; 25 | 26 | public function url_authorize() 27 | { 28 | return 'https://oauth.api.189.cn/emp/oauth2/authorize'; 29 | } 30 | 31 | public function url_access_token() 32 | { 33 | return 'https://oauth.api.189.cn/emp/oauth2/access_token'; 34 | } 35 | 36 | public function get_user_info(OAuth2_Token_Access $token) 37 | { 38 | 39 | $url = 'http://api.189.cn/upc/vitual_identity/user_network_info?type=json&'.http_build_query(array( 40 | 'access_token' => $token->access_token, 41 | 'app_id' => $this->client_id 42 | )); 43 | $user_network_info = json_decode(file_get_contents($url)); 44 | 45 | if (array_key_exists("error", $user_network_info)) 46 | { 47 | throw new OAuth2_Exception((array) $user_network_info); 48 | } 49 | 50 | // Create a response from the request 51 | return array( 52 | 'via' => 'tianyi', 53 | 'uid' => $token->uid, 54 | 'screen_name' => $user_network_info->user_nickname, 55 | 'name' => '', 56 | 'location' => '', 57 | 'description' => $user_network_info->user_selfdesc, 58 | 'image' => '', 59 | 'access_token' => $token->access_token, 60 | 'expire_at' => $token->expires, 61 | 'refresh_token' => $token->refresh_token 62 | ); 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /oauth2/Provider/Tweibo.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Tweibo extends OAuth2_Provider 11 | { 12 | public $name = 'tweibo'; 13 | 14 | public $human = '腾讯微博'; 15 | 16 | public $uid_key = 'openid'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://open.t.qq.com/cgi-bin/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://open.t.qq.com/cgi-bin/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | 33 | $url = 'https://open.t.qq.com/api/user/info?'.http_build_query(array( 34 | 'access_token' => $token->access_token, 35 | 'oauth_consumer_key' => $this->client_id, 36 | 'openid' => $token->uid, 37 | 'clientip' => get_instance()->input->ip_address(), 38 | 'oauth_version' => '2.a' 39 | )); 40 | $user = json_decode(file_get_contents($url)); 41 | 42 | if ($user->ret) 43 | { 44 | throw new OAuth2_Exception((array) $user); 45 | } 46 | 47 | // Create a response from the request 48 | return array( 49 | 'via' => 'tweibo', 50 | 'uid' => $user->data->openid, 51 | 'screen_name' => $user->data->nick, 52 | 'name' => $user->data->name, 53 | 'location' => '', 54 | 'description' => $user->data->introduction, 55 | 'image' => $user->data->head.'/100', 56 | 'access_token' => $token->access_token, 57 | 'expire_at' => $token->expires, 58 | 'refresh_token' => $token->refresh_token 59 | ); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /oauth2/Provider/Weibo.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class OAuth2_Provider_Weibo extends OAuth2_Provider 11 | { 12 | public $name = 'weibo'; 13 | 14 | public $human = '新浪微博'; 15 | 16 | public $uid_key = 'uid'; 17 | 18 | public $method = 'POST'; 19 | 20 | public function url_authorize() 21 | { 22 | return 'https://api.weibo.com/oauth2/authorize'; 23 | } 24 | 25 | public function url_access_token() 26 | { 27 | return 'https://api.weibo.com/oauth2/access_token'; 28 | } 29 | 30 | public function get_user_info(OAuth2_Token_Access $token) 31 | { 32 | $url = 'https://api.weibo.com/2/users/show.json?'.http_build_query(array( 33 | 'access_token' => $token->access_token, 34 | 'uid' => $token->uid, 35 | )); 36 | $user = json_decode(file_get_contents($url)); 37 | 38 | if (array_key_exists("error", $user)) 39 | { 40 | throw new OAuth2_Exception((array) $user); 41 | } 42 | 43 | return array( 44 | 'via' => 'weibo', 45 | 'uid' => $user->id, 46 | 'screen_name' => $user->screen_name, 47 | 'name' => $user->name, 48 | 'location' => $user->location, 49 | 'description' => $user->description, 50 | 'image' => $user->profile_image_url, 51 | 'access_token' => $token->access_token, 52 | 'expire_at' => $token->expires, 53 | 'refresh_token' => $token->refresh_token 54 | ); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /oauth2/Provider/Weixin.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | class Weixin extends Oauth2_Provider { 11 | 12 | const API_URL = 'https://api.weixin.qq.com/'; 13 | 14 | public $name = 'weixin'; 15 | 16 | public $human = '微信'; 17 | 18 | public $uid_key = 'openid'; 19 | 20 | public $client_id_key = 'appid'; 21 | 22 | public $client_secret_key = 'secret'; 23 | 24 | protected $scope = 'snsapi_userinfo'; 25 | 26 | public $method = 'POST'; 27 | 28 | public function scope_min() 29 | { 30 | $this->scope = 'snsapi_base'; 31 | } 32 | public function url_authorize() 33 | { 34 | return 'https://open.weixin.qq.com/connect/oauth2/authorize'; 35 | } 36 | 37 | public function url_access_token() 38 | { 39 | return 'https://api.weixin.qq.com/sns/oauth2/access_token'; 40 | } 41 | 42 | public function get_user_info(OAuth2_Token_Access $token) 43 | { 44 | $url = static::API_URL . 'sns/userinfo?'.http_build_query(array( 45 | 'access_token' => $token->access_token, 46 | 'openid' => $token->uid, 47 | 'lang' => 'zh_CN' 48 | )); 49 | $user = json_decode(file_get_contents($url)); 50 | if (array_key_exists("errcode", $user)) { 51 | throw new OAuth2_Exception((array) $user); 52 | } 53 | return array( 54 | 'via' => 'weixin', 55 | 'uid' => $user->openid, 56 | 'screen_name' => $user->nickname, 57 | 'name' => $user->nickname, 58 | 'location' => $user->province, 59 | 'description' => '', 60 | 'image' => $user->headimgurl, 61 | 'access_token' => $token->access_token, 62 | 'expire_at' => $token->expires, 63 | 'refresh_token' => $token->refresh_token 64 | ); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Appnet.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 42 | )); 43 | 44 | $user = json_decode(file_get_contents($url)); 45 | 46 | // Create a response from the request 47 | return array( 48 | 'uid' => $user->id, 49 | 'nickname' => $user->username, 50 | 'name' => $user->name 51 | ); 52 | 53 | } 54 | 55 | } -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Blooie.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 49 | )); 50 | 51 | $user = json_decode(file_get_contents($url)); 52 | 53 | // Create a response from the request 54 | return array( 55 | 'uid' => $user->id, 56 | 'nickname' => $user->username, 57 | 'name' => $user->name, 58 | 'first_name' => $user->first_name, 59 | 'last_name' => $user->last_name, 60 | 'email' => isset($user->email) ? $user->email : null, 61 | 'location' => isset($user->hometown->name) ? $user->hometown->name : null, 62 | 'description' => isset($user->bio) ? $user->bio : null, 63 | 'image' => 'https://graph.facebook.com/me/picture?type=normal&access_token='.$token->access_token, 64 | 'urls' => array( 65 | 'Facebook' => $user->link, 66 | ), 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Facebook.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 30 | )); 31 | 32 | $user = json_decode(file_get_contents($url)); 33 | 34 | // Create a response from the request 35 | return array( 36 | 'uid' => $user->id, 37 | 'nickname' => isset($user->username) ? $user->username : null, 38 | 'name' => $user->name, 39 | 'first_name' => $user->first_name, 40 | 'last_name' => $user->last_name, 41 | 'email' => isset($user->email) ? $user->email : null, 42 | 'location' => isset($user->hometown->name) ? $user->hometown->name : null, 43 | 'description' => isset($user->bio) ? $user->bio : null, 44 | 'image' => 'https://graph.facebook.com/me/picture?type=normal&access_token='.$token->access_token, 45 | 'urls' => array( 46 | 'Facebook' => $user->link, 47 | ), 48 | ); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Foursquare.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 30 | )); 31 | 32 | $response = json_decode(file_get_contents($url)); 33 | 34 | $user = $response->response->user; 35 | 36 | // Create a response from the request 37 | return array( 38 | 'uid' => $user->id, 39 | //'nickname' => $user->login, 40 | 'name' => sprintf('%s %s', $user->firstName, $user->lastName), 41 | 'email' => $user->contact->email, 42 | 'image' => $user->photo, 43 | 'location' => $user->homeCity, 44 | ); 45 | } 46 | } -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Github.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 28 | )); 29 | 30 | $user = json_decode(file_get_contents($url)); 31 | 32 | // Create a response from the request 33 | return array( 34 | 'uid' => $user->id, 35 | 'nickname' => $user->login, 36 | 'name' => $user->name, 37 | 'email' => $user->email, 38 | 'urls' => array( 39 | 'GitHub' => 'http://github.com/'.$user->login, 40 | 'Blog' => $user->blog, 41 | ), 42 | ); 43 | } 44 | } -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Google.php: -------------------------------------------------------------------------------- 1 | 'Expected Authorization Code from '.ucfirst($this->name).' is missing')); 59 | } 60 | 61 | return parent::access($code, $options); 62 | } 63 | 64 | public function get_user_info(OAuth2_Token_Access $token) 65 | { 66 | $url = 'https://www.googleapis.com/oauth2/v1/userinfo?alt=json&'.http_build_query(array( 67 | 'access_token' => $token->access_token, 68 | )); 69 | 70 | $user = json_decode(file_get_contents($url), true); 71 | return array( 72 | 'uid' => $user['id'], 73 | 'nickname' => url_title($user['name'], '_', true), 74 | 'name' => $user['name'], 75 | 'first_name' => $user['given_name'], 76 | 'last_name' => $user['family_name'], 77 | 'email' => $user['email'], 78 | 'location' => null, 79 | 'image' => (isset($user['picture'])) ? $user['picture'] : null, 80 | 'description' => null, 81 | 'urls' => array(), 82 | ); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Instagram.php: -------------------------------------------------------------------------------- 1 | user; 37 | 38 | return array( 39 | 'uid' => $user->id, 40 | 'nickname' => $user->username, 41 | 'name' => $user->full_name, 42 | 'image' => $user->profile_picture, 43 | 'urls' => array( 44 | 'website' => $user->website, 45 | ), 46 | ); 47 | } 48 | } -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Mailchimp.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 34 | ); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Mailru.php: -------------------------------------------------------------------------------- 1 | $value) { 29 | $params .= "$key=$value"; 30 | } 31 | return md5($params . $secret_key); 32 | } 33 | 34 | public function get_user_info(OAuth2_Token_Access $token) 35 | { 36 | $request_params = array( 37 | 'app_id' => $this->client_id, 38 | 'method' => 'users.getInfo', 39 | 'uids' => $token->uid, 40 | 'access_token' => $token->access_token, 41 | 'secure' => 1 42 | ); 43 | 44 | $sig = $this->sign_server_server($request_params,$this->client_secret); 45 | $url = 'http://www.appsmail.ru/platform/api?'.http_build_query($request_params).'&sig='.$sig; 46 | 47 | $user = json_decode(file_get_contents($url)); 48 | 49 | return array( 50 | 'uid' => $user[0]->uid, 51 | 'nickname' => $user[0]->nick, 52 | 'name' => $user[0]->first_name.' '.$user[0]->last_name, 53 | 'first_name' => $user[0]->first_name, 54 | 'last_name' => $user[0]->last_name, 55 | 'email' => isset($user[0]->email) ? $user[0]->email : null, 56 | 'image' => isset($user[0]->pic_big) ? $user[0]->pic_big : null, 57 | ); 58 | } 59 | 60 | public function authorize($options = array()) 61 | { 62 | $state = md5(uniqid(rand(), TRUE)); 63 | get_instance()->session->set_userdata('state', $state); 64 | 65 | $params = array( 66 | 'client_id' => $this->client_id, 67 | 'redirect_uri' => isset($options['redirect_uri']) ? $options['redirect_uri'] : $this->redirect_uri, 68 | 'response_type' => 'code', 69 | ); 70 | 71 | redirect($this->url_authorize().'?'.http_build_query($params)); 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Paypal.php: -------------------------------------------------------------------------------- 1 | $token->access_token 38 | )); 39 | 40 | $user = json_decode(file_get_contents($url),true); 41 | $user = $user['identity']; 42 | 43 | return array( 44 | 'uid' => $user['userId'], 45 | 'nickname' => url_title($user['fullName'], '_', true), 46 | 'name' => $user['fullName'], 47 | 'first_name' => $user['firstName'], 48 | 'last_name' => $user['lastName'], 49 | 'email' => $user['emails'][0], 50 | 'location' => $user->addresses[0], 51 | 'image' => null, 52 | 'description' => null, 53 | 'urls' => array( 54 | 'PayPal' => null 55 | ) 56 | ); 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Soundcloud.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 33 | )); 34 | 35 | $user = json_decode(file_get_contents($url)); 36 | 37 | // Create a response from the request 38 | return array( 39 | 'uid' => $user->id, 40 | 'nickname' => $user->username, 41 | 'name' => $user->full_name, 42 | 'location' => $user->country.' ,'.$user->country, 43 | 'description' => $user->description, 44 | 'image' => $user->avatar_url, 45 | 'urls' => array( 46 | 'MySpace' => $user->myspace_name, 47 | 'Website' => $user->website, 48 | ), 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Vkontakte.php: -------------------------------------------------------------------------------- 1 | $token->uid, 30 | 'fields' => implode(",",$scope), 31 | 'access_token' => $token->access_token, 32 | )); 33 | 34 | $user = json_decode(file_get_contents($url))->response; 35 | 36 | if(sizeof($user)==0) 37 | return null; 38 | else 39 | $user = $user[0]; 40 | 41 | return array( 42 | 'uid' => $user->uid, 43 | 'nickname' => isset($user->nickname) ? $user->nickname : null, 44 | 'name' => isset($user->name) ? $user->name : null, 45 | 'first_name' => isset($user->first_name) ? $user->first_name : null, 46 | 'last_name' => isset($user->last_name) ? $user->last_name : null, 47 | 'email' => null, 48 | 'location' => null, 49 | 'description' => null, 50 | 'image' => isset($user->photo_big) ? $user->photo_big : null, 51 | 'urls' => array(), 52 | ); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /oauth2/Provider/beyond the wall/Windowslive.php: -------------------------------------------------------------------------------- 1 | $token->access_token, 44 | )); 45 | 46 | // perform network request 47 | $user = json_decode(file_get_contents($url)); 48 | 49 | // create a response from the request and return it 50 | return array( 51 | 'uid' => $user->id, 52 | 'name' => $user->name, 53 | 'nickname' => url_title($user->name, '_', true), 54 | // 'location' => $user[''], # scope wl.postal_addresses is required 55 | # but won't be implemented by default 56 | 'locale' => $user->locale, 57 | 'urls' => array('Windows Live' => $user->link), 58 | ); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /oauth2/Token.php: -------------------------------------------------------------------------------- 1 | secret; 38 | * 39 | * @param string $key variable name 40 | * @return mixed 41 | */ 42 | public function __get($key) 43 | { 44 | return $this->$key; 45 | } 46 | 47 | /** 48 | * Return a boolean if the property is set 49 | * 50 | * // Get the token secret 51 | * if ($token->secret) exit('YAY SECRET'); 52 | * 53 | * @param string $key variable name 54 | * @return bool 55 | */ 56 | public function __isset($key) 57 | { 58 | return isset($this->$key); 59 | } 60 | 61 | } // End Token 62 | -------------------------------------------------------------------------------- /oauth2/Token/Access.php: -------------------------------------------------------------------------------- 1 | 16 | */ 17 | 18 | class OAuth2_Token_Access extends OAuth2_Token 19 | { 20 | /** 21 | * @var string access_token 22 | */ 23 | protected $access_token; 24 | 25 | /** 26 | * @var int expires 27 | */ 28 | protected $expires; 29 | 30 | /** 31 | * @var string refresh_token 32 | */ 33 | protected $refresh_token; 34 | 35 | /** 36 | * @var string uid 37 | */ 38 | protected $uid; 39 | 40 | /** 41 | * Sets the token, expiry, etc values. 42 | * 43 | * @param array $options token options 44 | * 45 | * @throws Exception if required options are missing 46 | */ 47 | public function __construct(array $options = null) 48 | { 49 | if ( ! isset($options[$options['access_token_key']])) 50 | { 51 | throw new Exception('Required option not passed: access_token'.PHP_EOL.print_r($options, true)); 52 | } 53 | 54 | // if ( ! isset($options['expires_in']) and ! isset($options['expires'])) 55 | // { 56 | // throw new Exception('We do not know when this access_token will expire'); 57 | // } 58 | 59 | $this->access_token = $options[$options['access_token_key']]; 60 | 61 | isset($options[$options['uid_key']]) and $this->uid = $options[$options['uid_key']]; 62 | 63 | //Mailru uses x_mailru_vid instead of uid 64 | isset($options['x_mailru_vid']) and $this->uid = $options['x_mailru_vid']; 65 | 66 | // We need to know when the token expires, add num. seconds to current time 67 | isset($options['expires_in']) and $this->expires = time() + ((int) $options['expires_in']); 68 | 69 | // Facebook is just being a spec ignoring jerk 70 | isset($options['expires']) and $this->expires = time() + ((int) $options['expires']); 71 | 72 | // Grab a refresh token so we can update access tokens when they expires 73 | isset($options['refresh_token']) and $this->refresh_token = $options['refresh_token']; 74 | } 75 | 76 | /** 77 | * Returns the token key. 78 | * 79 | * @return string 80 | */ 81 | public function __toString() 82 | { 83 | return (string) $this->access_token; 84 | } 85 | 86 | } // End OAuth2_Token_Access -------------------------------------------------------------------------------- /oauth2/Token/Authorize.php: -------------------------------------------------------------------------------- 1 | code = $options['code']; 42 | $this->redirect_uri = $options['redirect_uri']; 43 | } 44 | 45 | /** 46 | * Returns the token key. 47 | * 48 | * @return string 49 | */ 50 | public function __toString() 51 | { 52 | return (string) $this->code; 53 | } 54 | 55 | } // End OAuth2_Token_Access -------------------------------------------------------------------------------- /oauth2/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 | 7 |

Directory access is forbidden.

8 | 9 | 10 | --------------------------------------------------------------------------------