TijsVerkoyen\Dropbox\Dropbox::shares PHP Метод

shares() публичный Метод

Creates and returns a Dropbox link to files or folders users can use to view a preview of the file in a web browser.
public shares ( string $path, boolean $shortUrl = true, string[optional] $locale = null, bool[optional] $sandbox = false ) : array
$path string The path to the file.
$shortUrl boolean When true (default), the url returned will be shortened using the Dropbox url shortener. If false, the url will link directly to the file's preview page.
$locale string[optional]
$sandbox bool[optional]
Результат array
    public function shares($path, $shortUrl = true, $locale = null, $sandbox = false)
    {
        // build url
        $url = '1/shares/';
        $url .= $sandbox ? 'sandbox/' : 'dropbox/';
        $url .= trim((string) $path, '/');
        // build parameters
        $parameters['short_url'] = (bool) $shortUrl ? 'true' : 'false';
        if ($locale !== null) {
            $parameters['locale'] = (string) $locale;
        }
        // make the call
        return (array) $this->doCall($url, $parameters, 'POST');
    }

Usage Example

Пример #1
0
 /**
  * Tests Dropbox->shares()
  */
 public function testShares()
 {
     $response = $this->dropbox->shares(BASE_PATH);
     $this->assertArrayHasKey('url', $response);
     $this->assertArrayHasKey('expires', $response);
 }