Overview

Classes

  • Dropbox\AccessToken
  • Dropbox\AccessType
  • Dropbox\AppInfo
  • Dropbox\AuthInfo
  • Dropbox\Client
  • Dropbox\Config
  • Dropbox\Path
  • Dropbox\RequestToken
  • Dropbox\Token
  • Dropbox\WebAuth
  • Dropbox\WriteMode

Exceptions

  • Dropbox\AppInfoLoadException
  • Dropbox\AuthInfoLoadException
  • Dropbox\DeserializeException
  • Dropbox\Exception
  • Dropbox\Exception_BadRequest
  • Dropbox\Exception_BadResponse
  • Dropbox\Exception_BadResponseCode
  • Dropbox\Exception_InvalidAccessToken
  • Dropbox\Exception_NetworkIO
  • Dropbox\Exception_ProtocolError
  • Dropbox\Exception_RetryLater
  • Dropbox\Exception_ServerError
  • Overview
  • Class
  • Tree
 1: <?php
 2: namespace Dropbox;
 3: 
 4: /**
 5:  * This token is embedded in every API request so that the Dropbox server knows the request is
 6:  * authorized.  Each access token is associated with a specific application, so the Dropbox
 7:  * server knows which application is making requests.
 8:  *
 9:  * Do not share any of your access tokens with anybody, or they will be able to make
10:  * API requests pretending to be your application.
11:  *
12:  * You get an access token from {@link WebAuth::finish()}.
13:  *
14:  * <b>Storing Access Tokens</b>
15:  *
16:  * Once you have an access token, they are valid for many years and so you'll typically
17:  * store it somewhere long-lived, like a database or a file.
18:  *
19:  * You can convert this object into a single string using {@link AccessToken::serialize()},
20:  * and use {@link AccessToken::parse()} to convert that string back into an object.
21:  */
22: final class AccessToken extends Token
23: {
24:     /**
25:      * Tacked on to the front of the serialized string to distinguish it from other token types.
26:      *
27:      * @var string
28:      */
29:     private static $TypeTag = "a|";
30: 
31:     /**
32:      * @param string $key
33:      * @param string $value
34:      *
35:      * @internal
36:      */
37:     function __construct($key, $value)
38:     {
39:         parent::__construct($key, $value);
40:     }
41: 
42:     /**
43:      * Returns a string representation of this access token.  Can be convenient when
44:      * storing the access token to a file or database.
45:      *
46:      * @return string
47:      */
48:     function serialize()
49:     {
50:         return $this->serializeWithTag(self::$TypeTag);
51:     }
52: 
53:     /**
54:      * Convert a string generated by {@link serialize()} back into a {@link AccessToken}
55:      * object.
56:      *
57:      * @param string $data
58:      * @return AccessToken
59:      * @throws DeserializeException
60:      */
61:     static function deserialize($data)
62:     {
63:         $parts = parent::deserializeWithTag(self::$TypeTag, $data);
64:         return new AccessToken($parts[0], $parts[1]);
65:     }
66: 
67:     /**
68:      * Use this to check that a function argument is of type <code>AccessToken</code>.
69:      *
70:      * @internal
71:      */
72:     static function checkArg($argName, $argValue)
73:     {
74:         if (!($argValue instanceof self)) Checker::throwError($argName, $argValue, __CLASS__);
75:     }
76: 
77:     /**
78:      * Use this to check that a function argument is either <code>null</code> or of type
79:      * <code>AccessToken</code>.
80:      *
81:      * @internal
82:      */
83:     static function checkArgOrNull($argName, $argValue)
84:     {
85:         if ($argValue === null) return;
86:         if (!($argValue instanceof self)) Checker::throwError($argName, $argValue, __CLASS__);
87:     }
88: }
89: 
Dropbox SDK for PHP API documentation generated by ApiGen 2.8.0