[ Index ] |
PHP Cross Reference of phpBB-3.1.12-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 namespace OAuth\OAuth2\Service; 4 5 use OAuth\OAuth2\Token\StdOAuth2Token; 6 use OAuth\Common\Http\Exception\TokenResponseException; 7 use OAuth\Common\Http\Uri\Uri; 8 use OAuth\Common\Consumer\CredentialsInterface; 9 use OAuth\Common\Http\Client\ClientInterface; 10 use OAuth\Common\Storage\TokenStorageInterface; 11 use OAuth\Common\Http\Uri\UriInterface; 12 13 class Vkontakte extends AbstractService 14 { 15 /** 16 * Defined scopes 17 * 18 * @link http://vk.com/dev/permissions 19 */ 20 const SCOPE_NOTIFY = 'notify'; 21 const SCOPE_FRIENDS = 'friends'; 22 const SCOPE_PHOTOS = 'photos'; 23 const SCOPE_AUDIO = 'audio'; 24 const SCOPE_VIDEO = 'video'; 25 const SCOPE_DOCS = 'docs'; 26 const SCOPE_NOTES = 'notes'; 27 const SCOPE_PAGES = 'pages'; 28 const SCOPE_APP_LINK = ''; 29 const SCOPE_STATUS = 'status'; 30 const SCOPE_OFFERS = 'offers'; 31 const SCOPE_QUESTIONS = 'questions'; 32 const SCOPE_WALL = 'wall'; 33 const SCOPE_GROUPS = 'groups'; 34 const SCOPE_MESSAGES = 'messages'; 35 const SCOPE_NOTIFICATIONS = 'notifications'; 36 const SCOPE_STATS = 'stats'; 37 const SCOPE_ADS = 'ads'; 38 const SCOPE_OFFLINE = 'offline'; 39 const SCOPE_NOHTTPS = 'nohttps'; 40 41 public function __construct( 42 CredentialsInterface $credentials, 43 ClientInterface $httpClient, 44 TokenStorageInterface $storage, 45 $scopes = array(), 46 UriInterface $baseApiUri = null 47 ) { 48 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri); 49 50 if (null === $baseApiUri) { 51 $this->baseApiUri = new Uri('https://api.vk.com/method/'); 52 } 53 } 54 55 /** 56 * {@inheritdoc} 57 */ 58 public function getAuthorizationEndpoint() 59 { 60 return new Uri('https://oauth.vk.com/authorize'); 61 } 62 63 /** 64 * {@inheritdoc} 65 */ 66 public function getAccessTokenEndpoint() 67 { 68 return new Uri('https://oauth.vk.com/access_token'); 69 } 70 71 /** 72 * {@inheritdoc} 73 */ 74 protected function parseAccessTokenResponse($responseBody) 75 { 76 $data = json_decode($responseBody, true); 77 78 if (null === $data || !is_array($data)) { 79 throw new TokenResponseException('Unable to parse response.'); 80 } elseif (isset($data['error'])) { 81 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"'); 82 } 83 84 $token = new StdOAuth2Token(); 85 $token->setAccessToken($data['access_token']); 86 $token->setLifeTime($data['expires_in']); 87 88 if (isset($data['refresh_token'])) { 89 $token->setRefreshToken($data['refresh_token']); 90 unset($data['refresh_token']); 91 } 92 93 unset($data['access_token']); 94 unset($data['expires_in']); 95 96 $token->setExtraParams($data); 97 98 return $token; 99 } 100 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Jan 11 00:25:41 2018 | Cross-referenced by PHPXref 0.7.1 |