Example #1
0
    $error = 'Please enter all required parameters';
    F3::set('error', $error);
} else {
    //Get base path
    $basePath = F3::get('POST["basePath"]');
    //Get entered by user data
    $fileGuId = F3::get('POST["fileId"]');
    $url = F3::get('POST["url"]');
    $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
Example #2
0
 $basePath = F3::get('POST["basePath"]');
 //Get entered by user data
 $fileGuId = F3::get('POST["fileId"]');
 $url = F3::get('POST["url"]');
 $file = $_FILES['file'];
 F3::set('userId', $clientId);
 F3::set('privateKey', $privateKey);
 F3::set('email', $email);
 F3::set('firstName', $firstName);
 F3::set('lastName', $lastName);
 // 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);
 //Create MgmtApi object (this class allow manipulations with User account)
 $mgmtApi = new MgmtApi($apiClient);
 if ($basePath == "") {
     //If base base is empty seting base path to prod server
     $basePath = 'https://api.groupdocs.com/v2.0';
 }
 //Build propper basePath
 if (substr($basePath, -3) != "2.0") {
     if (substr($basePath, -1) != "/") {
         $basePath = $basePath . "/v2.0";
     } else {
         $basePath = $basePath . "v2.0";
     }
Example #3
0
if (empty($clientId) || empty($privateKey) || empty($fileId)) {
    $error = 'Please enter all required parameters';
    F3::set('error', $error);
} else {
    //Get base path
    $basePath = F3::get('POST["basePath"]');
    F3::set('userId', $clientId);
    F3::set('privateKey', $privateKey);
    F3::set('fileId', $fileId);
    #### 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);
    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);
    # Make a request to Annotation API using clientId and fileId
    try {
        $list = $antApi->ListAnnotations($clientId, $fileId);
        if ($list->status == "Ok") {
            // Check the result of the request
            if (isset($list->result)) {
                // If request was successfull - set annotations variable for template
                F3::set('annotations', $list->result->annotations);
            }
$guid = null;
//Get raw data
$json = file_get_contents("php://input");
//path to settings file - temporary save userId and apiKey like to property file
//Decode json with raw data to array
$callBack_data = json_decode($json, true);
$serializedData = json_decode($callBack_data['SerializedData'], true);
$documentGuid = $serializedData['DocumentGuid'];
$collaboratorGuid = $serializedData['UserGuid'];
if ($documentGuid != "" && $collaboratorGuid != '') {
    //Create signer object
    $signer = new GroupDocsRequestSigner(trim($privateKey));
    //Create apiClient object
    $apiClient = new APIClient($signer);
    //Create AsyncApi object
    $antApi = new AntApi($apiClient);
    //Get all collaborators for current document
    $getCollaborators = $antApi->GetAnnotationCollaborators($clientId, $documentGuid);
    if ($getCollaborators->status == "Ok") {
        //Create ReviewerInfo array
        $reviewer = new ReviewerInfo();
        //Loop for checking all collaborators
        for ($n = 0; $n < count($getCollaborators->result->collaborators); $n++) {
            //Set reviewer rights to view only
            if ($getCollaborators->result->collaborators[$n]->guid == $collaboratorGuid) {
                //Add riviewer to ReviewerInfo array
                $reviewer->id = $getCollaborators->result->collaborators[$n]->id;
                $reviewer->access_rights = 1;
                $reviewer = array($reviewer);
            }
        }
Example #5
0
             foreach ($files->result->files as $item) {
                 if ($item->guid == $fileGuId) {
                     $name = $item->name;
                 }
             }
         } else {
             throw new Exception($uploadResult->error_message);
         }
     } catch (Exception $e) {
         $error = 'ERROR: ' . $e->getMessage() . "\n";
         F3::set('error', $error);
     }
 }
 F3::set("fileId", $fileGuId);
 //Create Annotation Api object
 $antApi = new AntApi($apiClient);
 $antApi->setBasePath($basePath);
 try {
     //Set file sesion callback - will be trigered when user add, remove or edit commit for annotation
     $setCallback = $antApi->SetSessionCallbackUrl($clientID, $fileGuId, $callbackUrl);
     if ($setCallback->status == 'Ok') {
         //Generate iframe URL for iframe
         if ($basePath == "https://api.groupdocs.com/v2.0") {
             //iframe to prodaction server
             $url = "https://apps.groupdocs.com/document-annotation2/embed/" . $fileGuId;
             //iframe to dev server
         } elseif ($basePath == "https://dev-api.groupdocs.com/v2.0") {
             $url = 'https://dev-apps.groupdocs.com/document-annotation2/embed/' . $fileGuId;
             //iframe to test server
         } elseif ($basePath == "https://stage-api-groupdocs.dynabic.com/v2.0") {
             $url = 'https://stage-apps-groupdocs.dynabic.com/document-annotation2/embed/' . $fileGuId;
Example #6
0
 //Set nick name as entered first name
 $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") {
Example #7
0
 //Get base path
 $basePath = F3::get('POST["basePath"]');
 //Get entered by user data
 $fileGuId = F3::get('POST["fileId"]');
 $url = F3::get('POST["url"]');
 $file = $_FILES['file'];
 F3::set('userId', $clientId);
 F3::set('privateKey', $privateKey);
 F3::set('collaborations', $collaborations);
 //### 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
Example #8
0
try {
    if (empty($clientId) || empty($privateKey) || empty($fileId)) {
        throw new Exception('Please enter all required parameters');
    } else {
        //Get base path
        $basePath = F3::get('POST["basePath"]');
        F3::set('userId', $clientId);
        F3::set('privateKey', $privateKey);
        F3::set('fileId', $fileId);
        #### Create Signer, ApiClient and Annotation Api objects
        # Create signer object
        $signer = new GroupDocsRequestSigner($privateKey);
        # Create apiClient object
        $apiClient = new ApiClient($signer);
        # Create Annotation object
        $ant = new AntApi($apiClient);
        if ($basePath == "") {
            //If base base is empty seting base path to prod server
            $basePath = 'https://api.groupdocs.com/v2.0';
        }
        //Set base path
        $ant->setBasePath($basePath);
        # Make a request to Annotation API using clientId and fileId
        $list = $ant->ListAnnotations($clientId, $fileId);
        $message = "";
        // Check the result of the request
        if ($list->status == "Ok") {
            if (!empty($list->result->annotations)) {
                for ($i = 0; $i < count($list->result->annotations); $i++) {
                    $del = $ant->DeleteAnnotation($clientId, $list->result->annotations[$i]->guid);
                    if ($del->status == "Ok") {