dokNet.dk API


    Code example


    Tilknyt eksisterende respondent fra dokNet.dk til administrationssystem.

    Du tilknytter eksisterende respondent fra dokNet.dk til administrationssystem på https://doknet.dk/api/respondent/existing/attach);

    <?php
        // The authorization token
        $authorization = "Authorization: Bearer <token>";
     
    // The data to send to the API in an array
        $postData = array(
            'survey' => array(
                'sid' => '<sid>'),'
            respondent' => array(
                'rid' => '<rid>',
                'fid' => '<fid>'
            )
        );
        $data_string = json_encode($postData);
     
        // Setup cURL
        $ch = curl_init('https://doknet.dk/api/respondent/existing/attach'');
        curl_setopt_array($ch, array(
            CURLOPT_CUSTOMREQUEST => 'PUT',
            CURLOPT_RETURNTRANSFER => TRUE,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_HTTPHEADER => array( 'Content-Type: application/json', $authorization ),
            CURLOPT_POSTFIELDS => $data_string
        ));
     
        // Send the request
        $response = curl_exec($ch);
     
        // Check for errors
        if($response === FALSE){
            die(curl_error($ch));
        }
     
        // Print the data from the response
        echo $response . PHP_EOL;
    ?>