/**
  * Call this after the user has visited the authorize URL returned by {@link start()},
  * approved your app, was presented with an authorization code by Dropbox, and has copy/paste'd
  * that authorization code into your app.
  *
  * See <a href="https://www.dropbox.com/developers/core/docs#oa2-token">/oauth2/token</a>.
  *
  * @param string $code
  *                     The authorization code provided to the user by Dropbox.
  *
  * @return array
  *               A <code>list(string $accessToken, string $userId)</code>, where
  *               <code>$accessToken</code> can be used to construct a {@link Client} and
  *               <code>$userId</code> is the user ID of the user's Dropbox account.
  *
  * @throws Dropbox_Exception
  *                           Thrown if there's an error getting the access token from Dropbox.
  */
 public function finish($code)
 {
     Dropbox_Checker::argStringNonEmpty("code", $code);
     return $this->_finish($code, null);
 }
예제 #2
0
 /**
  * Constructor.
  *
  * @param Dropbox_AppInfo         $appInfo
  *                                                  See {@link getAppInfo()}
  * @param string                  $clientIdentifier
  *                                                  See {@link getClientIdentifier()}
  * @param null|string             $redirectUri
  *                                                  See {@link getRedirectUri()}
  * @param null|Dropbox_ValueStore $csrfTokenStore
  *                                                  See {@link getCsrfTokenStore()}
  * @param null|string             $userLocale
  *                                                  See {@link getUserLocale()}
  */
 public function __construct($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, $userLocale = null)
 {
     parent::__construct($appInfo, $clientIdentifier, $userLocale);
     Dropbox_Checker::argStringNonEmpty("redirectUri", $redirectUri);
     $this->csrfTokenStore = $csrfTokenStore;
     $this->redirectUri = $redirectUri;
 }
예제 #3
0
 /**
  * Creates a file or folder based on an existing copy ref (possibly from a different Dropbox
  * account).
  *
  * See <a href="https://www.dropbox.com/developers/core/docs#fileops-copy">/fileops/copy</a>.
  *
  * @param string $copyRef
  *                        A copy ref obtained via the {@link createCopyRef()} call.
  *
  * @param string $toPath
  *                       The Dropbox path you want to copy the file or folder to (UTF-8).
  *
  * @return mixed
  *               The <a href="https://www.dropbox.com/developers/core/docs#metadata-details">metadata
  *               object</a> for the new file or folder.
  *
  * @throws Dropbox_Exception
  */
 public function copyFromCopyRef($copyRef, $toPath)
 {
     Dropbox_Checker::argStringNonEmpty("copyRef", $copyRef);
     Dropbox_Path::checkArgNonRoot("toPath", $toPath);
     $response = $this->doPost($this->apiHost, "1/fileops/copy", array("root" => "auto", "from_copy_ref" => $copyRef, "to_path" => $toPath));
     if ($response->statusCode !== 200) {
         throw Dropbox_RequestUtil::unexpectedStatus($response);
     }
     return Dropbox_RequestUtil::parseResponseJson($response->body);
 }
예제 #4
0
 /**
  * @param string     $clientIdentifier
  * @param string     $accessToken
  * @param string     $userLocale
  * @param string     $host
  * @param string     $path
  * @param array|null $params
  *
  * @return Dropbox_HttpResponse
  *
  * @throws Dropbox_Exception
  */
 public static function doGet($clientIdentifier, $accessToken, $userLocale, $host, $path, $params = null)
 {
     Dropbox_Checker::argStringNonEmpty("accessToken", $accessToken);
     $url = self::buildUrlForGetOrPut($userLocale, $host, $path, $params);
     $curl = self::mkCurlWithOAuth($clientIdentifier, $url, $accessToken);
     $curl->set(CURLOPT_HTTPGET, true);
     $curl->set(CURLOPT_RETURNTRANSFER, true);
     return $curl->exec();
 }