forked from xjflyttp/yii2-oauth
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
23 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<?php | ||
|
||
namespace xj\oauth; | ||
|
||
use yii\authclient\OAuth2; | ||
|
@@ -8,17 +9,18 @@ | |
* Douban OAuth | ||
* @author light <[email protected]> | ||
*/ | ||
class DoubanAuth extends OAuth2 implements IAuth | ||
{ | ||
class DoubanAuth extends OAuth2 implements IAuth { | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $authUrl = 'https://www.douban.com/service/auth2/auth'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
public $tokenUrl = 'https://www.douban.com/service/auth2/token'; | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
|
@@ -35,23 +37,19 @@ class DoubanAuth extends OAuth2 implements IAuth | |
* @return array | ||
* @see http://developers.douban.com/wiki/?title=user_v2#User | ||
*/ | ||
public function getUserInfo() | ||
{ | ||
public function getUserInfo() { | ||
return $this->api('v2/user/~me', 'GET'); | ||
} | ||
|
||
protected function defaultName() | ||
{ | ||
protected function defaultName() { | ||
return 'douban'; | ||
} | ||
|
||
protected function defaultTitle() | ||
{ | ||
protected function defaultTitle() { | ||
return 'Douban'; | ||
} | ||
|
||
protected function defaultViewOptions() | ||
{ | ||
protected function defaultViewOptions() { | ||
return [ | ||
'popupWidth' => 800, | ||
'popupHeight' => 500, | ||
|
@@ -62,8 +60,7 @@ protected function defaultViewOptions() | |
* | ||
* @ineritdoc | ||
*/ | ||
public function api($apiSubUrl, $method = 'GET', array $params = [], array $headers = []) | ||
{ | ||
public function api($apiSubUrl, $method = 'GET', array $params = [], array $headers = []) { | ||
if (preg_match('/^https?:\\/\\//is', $apiSubUrl)) { | ||
$url = $apiSubUrl; | ||
} else { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
<?php | ||
|
||
namespace xj\oauth; | ||
|
||
use yii\authclient\OAuth2; | ||
|
||
/** | ||
* Renren OAuth | ||
* @author light <[email protected]> | ||
* @see http://wiki.dev.renren.com/wiki/Authentication | ||
*/ | ||
class RenrenAuth extends OAuth2 implements IAuth | ||
{ | ||
class RenrenAuth extends OAuth2 implements IAuth { | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
|
@@ -29,8 +32,7 @@ class RenrenAuth extends OAuth2 implements IAuth | |
* | ||
* @inheritdoc | ||
*/ | ||
protected function initUserAttributes() | ||
{ | ||
protected function initUserAttributes() { | ||
return $this->getAccessToken()->getParams()['user']; | ||
} | ||
|
||
|
@@ -40,34 +42,33 @@ protected function initUserAttributes() | |
* @see http://wiki.dev.renren.com/wiki/V2/user/get | ||
* @return array | ||
*/ | ||
public function getUserInfo() | ||
{ | ||
public function getUserInfo() { | ||
$user = $this->getUserAttributes(); | ||
return $this->api("v2/user/get", 'GET', ['userId' => $user['id']]); | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function defaultName() | ||
{ | ||
protected function defaultName() { | ||
return 'renren'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function defaultTitle() | ||
{ | ||
protected function defaultTitle() { | ||
return 'Renren'; | ||
} | ||
|
||
/** | ||
* @inheritdoc | ||
*/ | ||
protected function defaultViewOptions() | ||
{ | ||
protected function defaultViewOptions() { | ||
return [ | ||
'popupWidth' => 800, | ||
'popupHeight' => 500, | ||
]; | ||
} | ||
} | ||
|
||
} |