44 lines
1.2 KiB
PHP
44 lines
1.2 KiB
PHP
<?php
|
|
|
|
|
|
$apiToken="nCqnPnrt9HplICvOWhratTIrwkxqe7pILQ524GJG";
|
|
$dataCenter = "fra1"; // Example: "us-east-1"
|
|
$surveyId = "SV_3pyZVUNpxXm1PZI"; //Survey ID
|
|
$urveyId ="SV_bmiHoSHYWIgGM3I"; //Survey ID
|
|
//$surveyId = "SV_bmiHoSHYWIgGM3I"; //Survey ID
|
|
|
|
// API endpoint for getting survey details (simple GET request)
|
|
$surveyDetailsUrl = "https://$dataCenter.qualtrics.com/API/v3/surveys/$surveyId";
|
|
|
|
// cURL request to fetch survey details
|
|
$headers = [
|
|
"X-API-TOKEN: $apiToken",
|
|
"Content-Type: application/json"
|
|
];
|
|
|
|
$ch = curl_init($surveyDetailsUrl);
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
|
|
|
|
$response = curl_exec($ch);
|
|
curl_close($ch);
|
|
|
|
// Check for errors
|
|
if (!$response) {
|
|
die("Error fetching survey details: " . curl_error($ch));
|
|
}
|
|
|
|
// Check the response code
|
|
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
|
echo "HTTP Status Code: $httpCode\n";
|
|
|
|
// Decode the response to check if the API token is working
|
|
$surveyData = json_decode($response, true);
|
|
if (isset($surveyData['result'])) {
|
|
echo "Survey ID: " . $surveyData['result']['id'] . "\n";
|
|
} else {
|
|
echo "Error: " . json_encode($surveyData, JSON_PRETTY_PRINT) . "\n";
|
|
}
|
|
?>
|
|
|