Пример #1
0
 $file = $_FILES['file'];
 //### Create Signer, ApiClient and Annotation Api objects
 // Create signer object
 $signer = new GroupDocsRequestSigner($privateKey);
 // Create apiClient object
 $apiClient = new ApiClient($signer);
 // Create Annotation object
 $antApi = new AntApi($apiClient);
 //Create Storage Api object
 $storageApi = new StorageApi($apiClient);
 if ($basePath == "") {
     //If base base is empty seting base path to prod server
     $basePath = 'https://api.groupdocs.com/v2.0';
 }
 //Set base path
 $antApi->setBasePath($basePath);
 $storageApi->setBasePath($basePath);
 //Check if user choose upload file from URL
 if ($url != "") {
     $fileGuId = "";
     //Upload file from URL
     $uploadResult = $storageApi->UploadWeb($clientId, $url);
     //Check is file uploaded
     try {
         if ($uploadResult->status == "Ok") {
             //Get file GUID
             $fileId = $uploadResult->result->guid;
             //If it isn't uploaded throw exception to template
         } else {
             throw new Exception($uploadResult->error_message);
         }
Пример #2
0
 $user->nickname = $firstName;
 //Set first name as entered first name
 $user->firstname = $firstName;
 //Set last name as entered last name
 $user->lastname = $lastName;
 $user->roles = $roles;
 //Set email as entered email
 $user->primary_email = $email;
 //Creating of new user. $clientId - user id, $firstName - entered first name, $user - object with new user info
 $newUser = $mgmtApi->UpdateAccountUser($clientId, $email, $user);
 //Check the result of the request
 if ($newUser->status == "Ok") {
     //### If request was successfull
     //Create Annotation api object
     $ant = new AntApi($apiClient);
     $ant->setBasePath($basePath);
     //Create array with entered email for SetAnnotationCollaborators method
     $arrayEmail = array($email);
     //Make request to Ant api for set new user as annotation collaborator
     $addCollaborator = $ant->SetAnnotationCollaborators($clientId, $fileId, "2.0", $arrayEmail);
     if ($addCollaborator->status == "Ok") {
         //Make request to Annotation api to receive all collaborators for entered file id
         $getCollaborators = $ant->GetAnnotationCollaborators($clientId, $fileId);
         if ($getCollaborators->status == "Ok") {
             //Set reviewers rights for new user. $newUser->result->guid - GuId of created user, $fileId - entered file id,
             //$getCollaborators->result->collaborators - array of collabotors in which new user will be added
             $setReviewer = $ant->SetReviewerRights($newUser->result->guid, $fileId, $getCollaborators->result->collaborators);
             if ($setReviewer->status == "Ok") {
                 //Generating iframe for template
                 if ($basePath == "https://api.groupdocs.com/v2.0") {
                     $iframe = 'https://apps.groupdocs.com//document-annotation2/embed/' . $fileId . '?&uid=' . $newUser->result->guid . '&download=true';