Ejemplo n.º 1
0
    /**
    * Creates and returns a copy_ref to a file. This reference string can be used to copy that file to another user's Dropbox by passing it in as the from_copy_ref parameter on /fileops/copy.
    *
    * @param type $path
    * @param type $root
    * @return type
    */
    public function copy_ref($path, $root = null) {

    	if (is_null($root)) $root = $this->root;
    	$path = str_replace(array('%2F','~'), array('/','%7E'), rawurlencode($path));
    	$response = $this->oauth->fetch($this->api_url.  'copy_ref/'. $root . '/' . ltrim($path, '/'));
    	return json_decode($response['body'],true);

    }
Ejemplo n.º 2
0
 /**
  * Sets the request token and secret.
  *
  * The tokens can also be passed as an array into the first argument.
  * The array must have the elements token and token_secret.
  *
  * @param string|array $token
  * @param string $token_secret
  * @return void
  */
 public function setToken($token, $token_secret = null)
 {
     if (is_a($token, "Zend_Oauth_Token")) {
         if (is_a($token, "Zend_Oauth_Token_Access")) {
             $this->OAuth->setToken($token);
         }
         $this->zend_oauth_token = $token;
         return parent::setToken($token->getToken(), $token->getTokenSecret());
     } elseif (is_string($token) && is_null($token_secret)) {
         return $this->setToken(unserialize($token));
     } elseif (isset($token['zend_oauth_token'])) {
         return $this->setToken(unserialize($token['zend_oauth_token']));
     } else {
         parent::setToken($token, $token_secret);
         return;
     }
 }
 /**
  * This method is used to generate multipart POST requests for file upload 
  * 
  * @param string $uri 
  * @param array $arguments 
  * @return bool 
  */
 protected function multipartFetch($uri, $file, $filename)
 {
     /* random string */
     $boundary = 'R50hrfBj5JYyfR3vF3wR96GPCC9Fd2q2pVMERvEaOE3D8LZTgLLbRpNwXek3';
     $headers = array('Content-Type' => 'multipart/form-data; boundary=' . $boundary);
     $body = "--" . $boundary . "\r\n";
     $body .= "Content-Disposition: form-data; name=file; filename=" . $filename . "\r\n";
     $body .= "Content-type: application/octet-stream\r\n";
     $body .= "\r\n";
     $body .= stream_get_contents($file);
     $body .= "\r\n";
     $body .= "--" . $boundary . "--";
     // Dropbox requires the filename to also be part of the regular arguments, so it becomes
     // part of the signature.
     $uri .= '?file=' . $filename;
     return $this->oauth->fetch($uri, $body, 'POST', $headers);
 }
Ejemplo n.º 4
0
 /**
  * Sets the request token and secret.
  *
  * The tokens can also be passed as an array into the first argument.
  * The array must have the elements token and token_secret.
  * 
  * @param string|array $token 
  * @param string $token_secret 
  * @return void
  */
 public function setToken($token, $token_secret = null)
 {
     parent::setToken($token, $token_secret);
     $this->OAuth->setToken($this->oauth_token);
     $this->OAuth->setTokenSecret($this->oauth_token_secret);
 }