Verzeichnisstruktur phpBB-3.1.0
- Veröffentlicht
- 27.10.2014
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
Facebook.php
01 <?php
02 namespace OAuth\OAuth2\Service;
03
04 use OAuth\OAuth2\Token\StdOAuth2Token;
05 use OAuth\Common\Http\Exception\TokenResponseException;
06 use OAuth\Common\Http\Uri\Uri;
07 use OAuth\Common\Consumer\Credentials;
08 use OAuth\Common\Http\Client\ClientInterface;
09 use OAuth\Common\Storage\TokenStorageInterface;
10 use OAuth\Common\Http\Uri\UriInterface;
11
12 class Facebook extends AbstractService
13 {
14 public function __construct(Credentials $credentials, ClientInterface $httpClient, TokenStorageInterface $storage, $scopes = array(), UriInterface $baseApiUri = null)
15 {
16 parent::__construct($credentials, $httpClient, $storage, $scopes, $baseApiUri);
17 if( null === $baseApiUri ) {
18 $this->baseApiUri = new Uri('https://graph.facebook.com/');
19 }
20 }
21
22 /**
23 * @return \OAuth\Common\Http\Uri\UriInterface
24 */
25 public function getAuthorizationEndpoint()
26 {
27 return new Uri('https://www.facebook.com/dialog/oauth');
28 }
29
30 /**
31 * @return \OAuth\Common\Http\Uri\UriInterface
32 */
33 public function getAccessTokenEndpoint()
34 {
35 return new Uri('https://graph.facebook.com/oauth/access_token');
36 }
37
38 /**
39 * @param string $responseBody
40 * @return \OAuth\Common\Token\TokenInterface|\OAuth\OAuth2\Token\StdOAuth2Token
41 * @throws \OAuth\Common\Http\Exception\TokenResponseException
42 */
43 protected function parseAccessTokenResponse($responseBody)
44 {
45 // Facebook gives us a query string ... Oh wait. JSON is too simple, understand ?
46 parse_str($responseBody, $data);
47
48 if( null === $data || !is_array($data) ) {
49 throw new TokenResponseException('Unable to parse response.');
50 } elseif( isset($data['error'] ) ) {
51 throw new TokenResponseException('Error in retrieving token: "' . $data['error'] . '"');
52 }
53
54 $token = new StdOAuth2Token();
55
56 $token->setAccessToken( $data['access_token'] );
57 $token->setLifeTime( $data['expires'] );
58
59 if( isset($data['refresh_token'] ) ) {
60 $token->setRefreshToken( $data['refresh_token'] );
61 unset($data['refresh_token']);
62 }
63
64 unset( $data['access_token'] );
65 unset( $data['expires'] );
66 $token->setExtraParams( $data );
67
68 return $token;
69 }
70 }
71