Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
xjflyttp committed Dec 8, 2014
1 parent 33a7c94 commit ec44175
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
21 changes: 9 additions & 12 deletions DoubanAuth.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace xj\oauth;

use yii\authclient\OAuth2;
Expand All @@ -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
*/
Expand All @@ -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,
Expand All @@ -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 {
Expand Down
27 changes: 14 additions & 13 deletions RenrenAuth.php
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
*/
Expand All @@ -29,8 +32,7 @@ class RenrenAuth extends OAuth2 implements IAuth
*
* @inheritdoc
*/
protected function initUserAttributes()
{
protected function initUserAttributes() {
return $this->getAccessToken()->getParams()['user'];
}

Expand All @@ -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,
];
}
}

}

0 comments on commit ec44175

Please sign in to comment.