Function: pushToDataContainerTable

With this function you insert, update or delete your data in the Datacontainer tables. As a result you get the Operation / Process ID. In one API request, the operations Insert, Update and Delete can be mixed with their JSON structure and send to the contentDock API.

Request-program-example for pushToDataContainerTable
<?php

    # Your source code before
    # ...

    $contentdockApiKey = 'YourAPIKey';
    $contentdockClientSubdomain = 'YourContentDockSubDomain';
    $contentdockDataContainerTableID = YourTableID;
    $yourProgramAgent = 'YourProgramAgent';

    $importData = array();

    // Load your records to send to contentDock
    $yourRecords = $this->yourLoadRecordsFunction();

    // Populate Data records
    foreach ($yourRecords as $yourRecord) 
    {
        $data = array();
        $data['DataContainer-Field-Name'] = $yourRecord['Your-Data-Field'];
        $data['referenceUid'] = $yourRecord['Your-record-reference-id'];

        $importData[] = array('command' => 'insert', 'language' => 'EN', 'data' => $data);
    }

    // Build JSON
    $query =  json_encode ( 
                array (
                  "query" => 
                    array (
                      "command" => "pushToDataContainerTable",
                      "param" => 
                        array (
                          $contentdockApiKey,
                          $contentdockClientSubdomain,
                          $yourProgramAgent,
                          $contentdockDataContainerTableID,
                          $importData
                        )
                    )
                )
              );

    $requestData = array ( "data" => $query );

    $requestUrl = 'https://www.contentdock.com/api';

    // Init curl    
    $curl = curl_init ( $requestUrl );
    curl_setopt ( $curl, CURLOPT_POST, true );
    curl_setopt ( $curl, CURLOPT_POSTFIELDS, http_build_query ( $requestData ) );
    curl_setopt ( $curl, CURLOPT_USERAGENT,'contentDockAPI/1.0');
    curl_setopt ( $curl, CURLOPT_RETURNTRANSFER, true );

    // Exec curl
    $response = curl_exec ( $curl );

    curl_close ( $curl );
?>

More information


Feedback or Questions

We are always happy to help you with questions about the code or other questions.

Was this page helpful? Yes No

Topics on this page