本文整理汇总了PHP中API::userClear方法的典型用法代码示例。如果您正苦于以下问题:PHP API::userClear方法的具体用法?PHP API::userClear怎么用?PHP API::userClear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类API
的用法示例。
在下文中一共展示了API::userClear方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDownAfterClass
public static function tearDownAfterClass()
{
require 'include/config.inc.php';
API::userClear($config['userID']);
API::groupClear($config['ownedPrivateGroupID']);
}
示例2: testAddFileClientZip
public function testAddFileClientZip()
{
API::userClear(self::$config['userID']);
$auth = array('username' => self::$config['username'], 'password' => self::$config['password']);
// Get last storage sync
$response = API::userGet(self::$config['userID'], "laststoragesync?auth=1", array(), $auth);
$this->assert404($response);
$xml = API::createItem("book", false, $this);
$data = API::parseDataFromItemEntry($xml);
$key = $data['key'];
$fileContentType = "text/html";
$fileCharset = "UTF-8";
$fileFilename = "file.html";
$fileModtime = time();
$xml = API::createAttachmentItem("imported_url", $key, $this);
$data = API::parseDataFromItemEntry($xml);
$key = $data['key'];
$etag = $data['etag'];
$json = json_decode($data['content']);
$json->contentType = $fileContentType;
$json->charset = $fileCharset;
$json->filename = $fileFilename;
$response = API::userPut(self::$config['userID'], "items/{$key}?key=" . self::$config['apiKey'], json_encode($json), array("Content-Type: application/json", "If-Match: {$etag}"));
$this->assert200($response);
// Get file info
$response = API::userGet(self::$config['userID'], "items/{$data['key']}/file?auth=1&iskey=1&version=1&info=1", array(), $auth);
$this->assert404($response);
$zip = new ZipArchive();
$file = "work/{$key}.zip";
if ($zip->open($file, ZIPARCHIVE::CREATE) !== TRUE) {
throw new Exception("Cannot open ZIP file");
}
$zip->addFromString($fileFilename, self::getRandomUnicodeString());
$zip->addFromString("file.css", self::getRandomUnicodeString());
$zip->close();
$hash = md5_file($file);
$filename = $key . ".zip";
$size = filesize($file);
$fileContents = file_get_contents($file);
// Get upload authorization
$response = API::userPost(self::$config['userID'], "items/{$data['key']}/file?auth=1&iskey=1&version=1", $this->implodeParams(array("md5" => $hash, "filename" => $filename, "filesize" => $size, "mtime" => $fileModtime, "zip" => 1)), array("Content-Type: application/x-www-form-urlencoded"), $auth);
$this->assert200($response);
$this->assertContentType("application/xml", $response);
$xml = new SimpleXMLElement($response->getBody());
self::$toDelete[] = "{$hash}/{$filename}";
$boundary = "---------------------------" . rand();
$postData = "";
foreach ($xml->params->children() as $key => $val) {
$postData .= "--" . $boundary . "\r\nContent-Disposition: form-data; " . "name=\"{$key}\"\r\n\r\n{$val}\r\n";
}
$postData .= "--" . $boundary . "\r\nContent-Disposition: form-data; " . "name=\"file\"\r\n\r\n" . $fileContents . "\r\n";
$postData .= "--" . $boundary . "--";
// Upload to S3
$response = HTTP::post((string) $xml->url, $postData, array("Content-Type: multipart/form-data; boundary=" . $boundary));
$this->assert201($response);
//
// Register upload
//
$response = API::userPost(self::$config['userID'], "items/{$data['key']}/file?auth=1&iskey=1&version=1", "update=" . $xml->key . "&mtime=" . $fileModtime, array("Content-Type: application/x-www-form-urlencoded"), $auth);
$this->assert204($response);
// Verify attachment item metadata
$response = API::userGet(self::$config['userID'], "items/{$data['key']}?key=" . self::$config['apiKey'] . "&content=json");
$xml = API::getXMLFromResponse($response);
$json = json_decode(array_shift($xml->xpath('/atom:entry/atom:content')));
$this->assertEquals($hash, $json->md5);
$this->assertEquals($fileFilename, $json->filename);
$this->assertEquals($fileModtime, $json->mtime);
$response = API::userGet(self::$config['userID'], "laststoragesync?auth=1", array(), array('username' => self::$config['username'], 'password' => self::$config['password']));
$this->assert200($response);
$mtime = $response->getBody();
$this->assertRegExp('/^[0-9]{10}$/', $mtime);
// File exists
$response = API::userPost(self::$config['userID'], "items/{$data['key']}/file?auth=1&iskey=1&version=1", $this->implodeParams(array("md5" => $hash, "filename" => $filename, "filesize" => $size, "mtime" => $fileModtime + 1000, "zip" => 1)), array("Content-Type: application/x-www-form-urlencoded"), $auth);
$this->assert200($response);
$this->assertContentType("application/xml", $response);
$this->assertEquals("<exists/>", $response->getBody());
}
示例3: tearDownAfterClass
public static function tearDownAfterClass()
{
parent::tearDownAfterClass();
API::userClear(self::$config['userID']);
}
示例4: tearDownAfterClass
public static function tearDownAfterClass()
{
parent::tearDownAfterClass();
API::userClear(self::$config['userID']);
API::groupClear(self::$config['ownedPrivateGroupID']);
}
示例5: setUp
public function setUp()
{
API::userClear(self::$config['userID']);
self::$sessionID = Sync::login();
}