Dokumentation för API-funktioner
POST PublicAdvertising/Estate/{customerId}/hits/hourly Rapportera besöksstatistik per timme för marknadsplatser. Rapportering är kumulativ. Request Information URI Parameters
NamnBeskrivningTypInformation
customerId Kund-id string Krävs
Body Parameters Besök Collection of HourlyEstateHit
NamnBeskrivningTypInformation
Hour Timme mellan 0-23. Ex. 8 anger intervallet 8.00-9.00 integer

EstateId ObjektId string

Date Dag för besöket. (ev. tidangivelse ignoreras) date

Count Antal besök. integer

Request Formats

[
  {
    "hour": 1,
    "estateId": "sample string 2",
    "date": "2024-05-02T09:31:01.071159+02:00",
    "count": 4
  },
  {
    "hour": 1,
    "estateId": "sample string 2",
    "date": "2024-05-02T09:31:01.071159+02:00",
    "count": 4
  }
]
<ArrayOfHourlyEstateHit xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.datacontract.org/2004/07/Express.Connect.Api.Models.PublicAdvertisement.Hits">
  <HourlyEstateHit>
    <Count>4</Count>
    <Date>2024-05-02T09:31:01.071159+02:00</Date>
    <EstateId>sample string 2</EstateId>
    <Hour>1</Hour>
  </HourlyEstateHit>
  <HourlyEstateHit>
    <Count>4</Count>
    <Date>2024-05-02T09:31:01.071159+02:00</Date>
    <EstateId>sample string 2</EstateId>
    <Hour>1</Hour>
  </HourlyEstateHit>
</ArrayOfHourlyEstateHit>
Response Information Resource Description Rapportera besöksstatistik per timme för marknadsplatser. Rapportering är kumulativ.

Kodexempel

curl "https://connect.maklare.vitec.net/PublicAdvertising/Estate/StringValue/hits/hourly" -X POST -H "Content-Type: application/json" -H "Authorization: basic {Base64 kodad användarnamn och lösenord}" -d [{\"hour\":0,\"estateId\":\"StringValue\",\"date\":\"2015-01-01T12:00:00\"}]
            

$URL = "https://connect.maklare.vitec.net/PublicAdvertising/Estate/StringValue/hits/hourly"
$data = "[{`"hour`":0,`"estateId`":`"StringValue`",`"date`":`"2015-01-01T12:00:00`"}]"
Invoke-WebRequest -Uri $URL -Method POST -Headers @{"Content-Type" = "application/json"; "authorization" = "basic {Base64 kodad användarnamn och lösenord}"} -Body $data
                

// HttpClientInstance ska deklareras som en singleton
// public static readonly HttpClient HttpClientInstance = new HttpClient {
//     BaseAddress = new Uri("https://connect.maklare.vitec.net"),
//     DefaultRequestHeaders = {
//         Authorization = new AuthenticationHeaderValue("Basic", "{Base64 kodad användarnamn och lösenord}")
//     }
// }
var json = "[{\"hour\":0,\"estateId\":\"StringValue\",\"date\":\"2015-01-01T12:00:00\"}]";
using (var response = await HttpClientInstance.PostAsync("PublicAdvertising/Estate/StringValue/hits/hourly", new StringContent(json, Encoding.UTF8, "application/json"))) {
    if (response.StatusCode == HttpStatusCode.Unauthorized) {
        // Authorization headern är inte korrekt
    }
    if (response.StatusCode == HttpStatusCode.Forbidden) {
        // Begärt data som det saknas åtkomst till
    }
    if (response.StatusCode == HttpStatusCode.InternalServerError) {
        // Oväntat fel, kontakta Vitec
    }
    if (response.StatusCode == HttpStatusCode.BadRequest) {
        var json = await response.Content.ReadAsStringAsync();
        var result = JsonConvert.DeserializeObject<dynamic>(json);
        // Hantera valideringsfel, presenteras i resultatet
    }
}

$URL = "https://connect.maklare.vitec.net/PublicAdvertising/Estate/StringValue/hits/hourly";

$ch = curl_init();

curl_setopt($ch, CURLOPT_USERNAME, "{Användarnamn}");
curl_setopt($ch, CURLOPT_PASSWORD, "{Lösenord}");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $URL);
$data = "[{\"hour\":0,\"estateId\":\"StringValue\",\"date\":\"2015-01-01T12:00:00\"}]";
curl_setopt($ch, CURLOPT_POST, true);

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Content-Type: application/json',
    'Content-Length: ' . strlen($data)
));

$result = curl_exec($ch);

if (curl_errno($ch)) {
    die(curl_getinfo($ch));
}

$info = curl_getinfo($ch);
curl_close($ch);

$http_code = $info["http_code"];
if ($http_code == 401) {
    // Användarnamnet eller lösenordet är felaktigt
}
if ($http_code == 403) {
    // Begärt data som det saknas åtkomst till
}
if ($http_code == 500) {
    // Oväntat fel, kontakta Vitec
}
if ($http_code == 400) {
    $json = json_decode($result, true);
    // Hantera valideringsfel, presenteras i $json
}

Testformulär Text input