/**
  * Constructor.
  *
  * @param AppInfo $appInfo
  *     See {@link getAppInfo()}
  * @param string $clientIdentifier
  *     See {@link getClientIdentifier()}
  * @param null|string $userLocale
  *     See {@link getUserLocale()}
  */
 function __construct($appInfo, $clientIdentifier, $userLocale = null)
 {
     AppInfo::checkArg("appInfo", $appInfo);
     Checker::argStringNonEmpty("clientIdentifier", $clientIdentifier);
     Checker::argStringNonEmptyOrNull("userLocale", $userLocale);
     $this->appInfo = $appInfo;
     $this->clientIdentifier = $clientIdentifier;
     $this->userLocale = $userLocale;
 }
Ejemplo n.º 2
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 Exception
  */
 function copyFromCopyRef($copyRef, $toPath)
 {
     Checker::argStringNonEmpty("copyRef", $copyRef);
     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 RequestUtil::unexpectedStatus($response);
     }
     return RequestUtil::parseResponseJson($response->body);
 }
Ejemplo n.º 3
0
 /**
  * @param string $clientIdentifier
  * @param string $accessToken
  * @param string $userLocale
  * @param string $host
  * @param string $path
  * @param array|null $params
  *
  * @return HttpResponse
  *
  * @throws Exception
  */
 static function doGet($clientIdentifier, $accessToken, $userLocale, $host, $path, $params = null)
 {
     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();
 }
Ejemplo n.º 4
0
 /**
  * Constructor.
  *
  * @param AppInfo $appInfo
  *     See {@link getAppInfo()}
  * @param string $clientIdentifier
  *     See {@link getClientIdentifier()}
  * @param null|string $redirectUri
  *     See {@link getRedirectUri()}
  * @param null|ValueStore $csrfTokenStore
  *     See {@link getCsrfTokenStore()}
  * @param null|string $userLocale
  *     See {@link getUserLocale()}
  */
 function __construct($appInfo, $clientIdentifier, $redirectUri, $csrfTokenStore, $userLocale = null)
 {
     parent::__construct($appInfo, $clientIdentifier, $userLocale);
     Checker::argStringNonEmpty("redirectUri", $redirectUri);
     $this->csrfTokenStore = $csrfTokenStore;
     $this->redirectUri = $redirectUri;
 }
 /**
  * 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 Exception
  *    Thrown if there's an error getting the access token from Dropbox.
  */
 function finish($code)
 {
     Checker::argStringNonEmpty("code", $code);
     return $this->_finish($code, null);
 }
Ejemplo n.º 6
0
 /**
  * @internal
  *
  * @param string $argName
  * @param mixed $value
  * @throws \InvalidArgumentException
  */
 static function checkArgNonRoot($argName, $value)
 {
     Checker::argStringNonEmpty($argName, $value);
     $error = self::findErrorNonRoot($value);
     if ($error !== null) {
         throw new \InvalidArgumentException("'{$argName}': bad path: {$error}: " . Util::q($value));
     }
 }