Open vladus-06 opened 4 years ago
Can someone help me with this code? What am I doing wrong?
class ApiTest
{
private $_api;
public function testAdminWaitSet()
{
$api = AdminFactory::instance('https://localhost:7071/service/admin/soap');
$api->auth('admin', '************');
$name = 'admin@mail.local.com';
$id = '7ac0ebb7-2bd5-4c48-828c-74cbc0e636d1';
$token = '0_78f6491445198621727b10d20104482cc46fa509_69643d33363a37616330656262372d326264352d346334382d383238632d3734636263306536333664313b6578703d31333a313630333835323430383236383b61646d696e3d313a313b747970653d363a7a696d6272613b753d313a613b7469643d393a3835363634343238383b76657273696f6e3d31343a382e382e31355f47415f333836393b';
$waitSet = 1;//self::randomName();
$seq = 1;//self::randomName();
$timeout = 1000; //mt_rand(0, 1000);
$a = new \Zimbra\Struct\WaitSetAddSpec($name, $id, $token, [InterestType::FOLDERS(), InterestType::MESSAGES(), InterestType::CONTACTS()]);
$add = new \Zimbra\Struct\WaitSetSpec([$a]);
$update = new \Zimbra\Struct\WaitSetSpec([$a]);
$a = new \Zimbra\Struct\Id($id);
$remove = new \Zimbra\Struct\WaitSetId([$a]);
$api->adminWaitSet($waitSet, $seq, $add, $update, $remove, true, [InterestType::FOLDERS(), InterestType::MESSAGES()], $timeout);
$client = $api->client();
$req = $client->lastRequest();
$xml = '<?xml version="1.0"?>' .
"\n" . '<env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope" xmlns:urn="urn:zimbra" xmlns:urn1="urn:zimbraAdmin">' .
'<env:Body>' . '<urn1:AdminWaitSetRequest waitSet="' .
$waitSet . '" seq="' . $seq . '" block="true" defTypes="f,m" timeout="' . $timeout . '" >' . '<urn1:add>' . '<urn1:a name="' .
$name . '" id="' . $id . '" token="' . $token . '" types="f,m,c" />' . '</urn1:add>' . '<urn1:update>' . '<urn1:a name="' .
$name . '" id="' . $id . '" token="' . $token . '" types="f,m,c" />' . '</urn1:update>' . '<urn1:remove>' . '<urn1:a id="' .
$id . '" />' . '</urn1:remove>' . '</urn1:AdminWaitSetRequest>' . '</env:Body>' . '</env:Envelope>';
// $this->assertXmlStringEqualsXmlString($xml, (string) $req);
return $xml;
}
}
$qwe = new ApiTest;
echo $qwe->testAdminWaitSet();
PHP Fatal error: Uncaught GuzzleHttp\Exception\ServerException: Server error: POST https://localhost:7071/service/admin/soap
resulted in a 500 Server Error
response:
Hi. How i can use WaitSet? I want to listen to all Zimbra accounts тo see when new letters arrive.
require 'vendor/autoload.php';
$api = AdminFactory::instance('https://localhost:7071/service/admin/soap'); $api->auth('admin', 'paddword');
$accounts = array(); $interests = array('m');
$waitset = new AdminCreateWaitSet(); $waitset->setAllAccounts(TRUE); ........ var_dump($waitset);