Malformed Notification XMLs

  • akacfa

    60 berichten

    Nederland

    Dear support,

    We are using the Notification system to get notified by the changes of our items.
    We experience "casual" problems when receiving notification data. We get always some cryptic decoding error in our system.
    Investigating the issue it seems that the text fields in the notification xmls are not properly encoded, so they are invalid xmls.
    Please encode the value of the "item_title" tag also!

    For example: (Please, note the & in the middle of tag)

    XXXXXXXXXXXXXXXX
    2021-06-22T10:26:13+00:00
    Seller_Item_Close_Sold

    1273859545
    akacfa
    CPM AK ZKH Prins Willem-Alexander & HKH Prinses Maxima DUTCH ROYALTY (785913)
    4.99
    EUR
    1
    0

    https%3A%2F%2Fwww.delcampe.net%2Fen_GB%2Fcollectables%2Fitem%2F1273859545.html%3Futm_source%3Dnewsletter%26utm_medium%3Demail
    %26utm_campaign%3Dsold_item.xml.twig
    0
    5
    XXXXXXXXXXX
    XXXXXXXXXXX
    XXXXXXXXXXX
    English (United Kingdom), French
    XXXXXXXXXXX
    XXXXXXXXXXX
    XXXXXXXXXXX
    XXXXXXXXXXX
    XXXXXXXXXXX
    XXXXXXXXXXX

    XXXXXXXXXXX
    XXXXXXXXXXX
    XXXXXXXXXXX
    XXXXXXXXXXX
    https%3A%2F%2Fwww.delcampe.net%2Fen_GB%2Fcollectables%2Fitem%2F1273859545.html%3Futm_source%3Dnewsletter%26utm_medium%3Dema
    il%26utm_campaign%3Dsold_item.xml.twig%23tab-rates



    Best regards,
    Gergely
  • akacfa

    60 berichten

    Nederland

    I resubmit example replacing angle brackets with quotation mark.

    "Delcampe_Notification"
    "Notification_Token"XXXXXXXXXXXXXXX"/Notification_Token"
    "Notification_Datetime"2021-06-22T10:26:13+00:00"/Notification_Datetime"
    "Notification_Type"Seller_Item_Close_Sold"/Notification_Type"
    "Notification_Data"
    "id_item"1273859545"/id_item"
    "seller_nickname"akacfa"/seller_nickname"
    "item_title"CPM AK ZKH Prins Willem-Alexander & HKH Prinses Maxima DUTCH ROYALTY (785913)"/item_title"
    "best_bid"4.99"/best_bid"
    "best_bid_currency"EUR"/best_bid_currency"
    "qty"1"/qty"
    "available_quantity"0"/available_quantity"
    "personal_reference""/personal_reference"
    "url_to_item"https%3A%2F%2Fwww.delcampe.net%2Fen_GB%2Fcollectables%2Fitem%2F1273859545.html%3Futm_source%3Dnewsletter%26utm_medium%3Demail
    %26utm_campaign%3Dsold_item.xml.twig"/url_to_item"
    "bids_qty"0"/bids_qty"
    "visits_counter"5"/visits_counter"
    "buyer_id"XXXXXXXXX"/buyer_id"
    "buyer_nickname"XXXXXXXXX"/buyer_nickname"
    "buyer_email"XXXXXXXXX"/buyer_email"
    "buyer_spoken_languages"English (United Kingdom), French"/buyer_spoken_languages"
    "buyer_language"XXXXXXXXX"/buyer_language"
    "buyer_firstname"XXXXXXXXX"/buyer_firstname"
    "buyer_surname"XXXXXXXXX"/buyer_surname"
    "buyer_address"XXXXXXXXX"/buyer_address"
    "buyer_zipcode"XXXXXXXXX"/buyer_zipcode"
    "buyer_city"XXXXXXXXX"/buyer_city"
    "buyer_state""/buyer_state"
    "buyer_country"XXXXXXXXX"/buyer_country"
    "buyer_phone"XXXXXXXXX"/buyer_phone"
    "buyer_rating_nbr"XXXXXXXXX"/buyer_rating_nbr"
    "buyer_rating_percentage"100"/buyer_rating_percentage"
    "url_to_rating"https%3A%2F%2Fwww.delcampe.net%2Fen_GB%2Fcollectables%2Fitem%2F1273859545.html%3Futm_source%3Dnewsletter%26utm_medium%3Dema
    il%26utm_campaign%3Dsold_item.xml.twig%23tab-rates"/url_to_rating"
    "/Notification_Data"
    "/Delcampe_Notification"
  • @thomas
    Rekening afgesloten

    348 berichten

    België

    I resubmit example replacing angle brackets with quotation mark.

    "Delcampe_Notification"
    "Notification_Token"XXXXXXXXXXXXXXX"/Notification_Token"
    "Notification_Datetime"2021-06-22T10:26:13+00:00"/Notification_Datetime"
    "Notification_Type"Seller_Item_Close_Sold"/Notification_Type"
    "Notification_Data"
    "id_item"1273859545"/id_item"
    "seller_nickname"akacfa"/seller_nickname"
    "item_title"CPM AK ZKH Prins Willem-Alexander & HKH Prinses Maxima DUTCH ROYALTY (785913)"/item_title"
    "best_bid"4.99"/best_bid"
    "best_bid_currency"EUR"/best_bid_currency"
    "qty"1"/qty"
    "available_quantity"0"/available_quantity"
    "personal_reference""/personal_reference"
    "url_to_item"https%3A%2F%2Fwww.delcampe.net%2Fen_GB%2Fcollectables%2Fitem%2F1273859545.html%3Futm_source%3Dnewsletter%26utm_medium%3Demail
    %26utm_campaign%3Dsold_item.xml.twig"/url_to_item"
    "bids_qty"0"/bids_qty"
    "visits_counter"5"/visits_counter"
    "buyer_id"XXXXXXXXX"/buyer_id"
    "buyer_nickname"XXXXXXXXX"/buyer_nickname"
    "buyer_email"XXXXXXXXX"/buyer_email"
    "buyer_spoken_languages"English (United Kingdom), French"/buyer_spoken_languages"
    "buyer_language"XXXXXXXXX"/buyer_language"
    "buyer_firstname"XXXXXXXXX"/buyer_firstname"
    "buyer_surname"XXXXXXXXX"/buyer_surname"
    "buyer_address"XXXXXXXXX"/buyer_address"
    "buyer_zipcode"XXXXXXXXX"/buyer_zipcode"
    "buyer_city"XXXXXXXXX"/buyer_city"
    "buyer_state""/buyer_state"
    "buyer_country"XXXXXXXXX"/buyer_country"
    "buyer_phone"XXXXXXXXX"/buyer_phone"
    "buyer_rating_nbr"XXXXXXXXX"/buyer_rating_nbr"
    "buyer_rating_percentage"100"/buyer_rating_percentage"
    "url_to_rating"https%3A%2F%2Fwww.delcampe.net%2Fen_GB%2Fcollectables%2Fitem%2F1273859545.html%3Futm_source%3Dnewsletter%26utm_medium%3Dema
    il%26utm_campaign%3Dsold_item.xml.twig%23tab-rates"/url_to_rating"
    "/Notification_Data"
    "/Delcampe_Notification"
    • Aangemaakt 22 jun 2021 op 15:28
    • #1294732
    Hello akacfa,

    I have done various tests and have not found any encoding problems.
    What language or library are you using to read our XML notifications?

    Best Regards,
    --
    Thomas
    Delcampe Team
  • akacfa

    60 berichten

    Nederland

    Hello Thomas,

    We use the PHP DomDocument class.
    But anyway a bare "&" character inside a tag is an invalid character.

    Best regards,
    Gergely
  • akacfa

    60 berichten

    Nederland

    Hello Thomas,
    Can you confirm this?
    Gergely
  • akacfa

    60 berichten

    Nederland

    Hi!

    If somebody in this case try to use the following "patch".

    private function cleanupReceivedXML(string $notification_xml): string
    {
    // Cleanup tag
    $matches = [];
    preg_match('/(.+)<\/item_title>/', $notification_xml, $matches);

    if( isset($matches[1]) && strlen($matches[1]) > 0 )
    {
    $new_item_title = htmlspecialchars($matches[1], ENT_XML1);

    $notification_xml = str_replace('' . $matches[1] . '',
    '' . $new_item_title . '',
    $notification_xml);
    }

    return $notification_xml;
    }
  • akacfa

    60 berichten

    Nederland

    Hi!

    Check the "solution" in the following link:
    Link (https)

    Gergely
  • @thomas
    Rekening afgesloten

    348 berichten

    België

    Hi!

    Check the "solution" in the following link:
    Link (https)

    Gergely
    • Aangemaakt 1 jul 2021 op 03:39
    • #1300564
    Hello Gergely,

    Sorry for my late reply.

    Indeed the ampersand character is not valid in XML but we escape the character to have "&". Which makes the xml valid.

    Best Regards,
    --
    Thomas
    Delcampe Team

Word lid van de verzamelaars-community!

Registreren Aanmelden