dokNet.dk API


    Code example


    Opdater respondent

    Du opdaterer oplysninger om en respondent på adressen https://doknet.dk/api/respondent/update

    Eksempel ved hjælp af PHP og curl

    <?php
        // The authorization token
        $authorization = "Authorization: Bearer <token>";
     
        // The data to send to the API in an array
        $postData = array(
              'respondent' => array(
                      'fid' => '<fid>',
                      'firstName' => '<firstName>',
                      'lastName' => '<lastName>',
                      'email' => '<email>',
                      'mobilecountrycode' => '<mobilecountrycode>',
                      'mobile' => '<mobile>',
                      'borndate' => '<borndate>'
                          )
                  );
        $data_string = json_encode($postData);
     
        // Setup cURL
        $ch = curl_init('https://doknet.dk/api/respondent/update');
        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;
    ?>