问题
I'm trying to send a Flight confirmation email with markups in order to get highlighted the flight information in Gmail.
This is the markup:
<script type="application/ld+json">
[
{
"@context": "http://schema.org",
"@type": "FlightReservation",
"reservationNumber": "PNR TEST",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "Prenom Nom"
},
"reservationFor": {
"@type": "Flight",
"flightNumber": "2712",
"airline": {"@type": "Airline","name": "IBERIA","iataCode": "IB"},
"departureAirport": {"@type": "Airport","name": "Madrid","iataCode": "MAD"},
"departureTime": "Tue Sep 08 06:50:00 CEST 2015",
"arrivalAirport": {"@type": "Airport","name": "Barcelona","iataCode": "BCN"},
"arrivalTime": "Tue Sep 08 08:00:00 CEST 2015"
}
},
{
"@context": "http://schema.org",
"@type": "FlightReservation",
"reservationNumber": "PNR TEST",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "Prenom Nom"
},
"reservationFor": {
"@type": "Flight",
"flightNumber": "2739",
"airline": {"@type": "Airline","name": "IBERIA","iataCode": "IB"},
"departureAirport": {"@type": "Airport","name": "Barcelona","iataCode": "BCN"},
"departureTime": "Thu Sep 10 06:50:00 CEST 2015",
"arrivalAirport": {"@type": "Airport","name": "Madrid","iataCode": "MAD"},
"arrivalTime": "Thu Sep 10 08:10:00 CEST 2015"
}
} ]
</script>
When I don't include this markup in the email, gmail is showing flight info automatically, but sometimes there is some wrong info.
Now, when I include the markup, that passes the Google Markup Test, Gmail doesn't show Flight Highlight. I have tried it with my personal account as sender and as recipient in order to ignore the registration requirements, like I have read here, but this is not working.
Could you give me some indication?
回答1:
Your DateTime formatting is not correct. Per the documentation:
(DateTime values are expected to be in the ISO 8601 format, for example '2013-02-14T13:15:03-08:00' (YYYY-MM-DDTHH:mm:ssZ).
When I tested your markup, I wasn't able to generate anything in Inbox, however, when I changed the departureTime and arrivalTime attributes in your markup, I was able to generate actions.
<script type="application/ld+json">
[
{
"@context": "http://schema.org",
"@type": "FlightReservation",
"reservationNumber": "PNR TEST",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "Prenom Nom"
},
"reservationFor": {
"@type": "Flight",
"flightNumber": "2712",
"airline": {"@type": "Airline","name": "IBERIA","iataCode": "IB"},
"departureAirport": {"@type": "Airport","name": "Madrid","iataCode": "MAD"},
"departureTime": "2015-10-20T13:15:03-08:00",
"arrivalAirport": {"@type": "Airport","name": "Barcelona","iataCode": "BCN"},
"arrivalTime": "2015-10-20T18:15:03-08:00"
}
},
{
"@context": "http://schema.org",
"@type": "FlightReservation",
"reservationNumber": "PNR TEST",
"reservationStatus": "http://schema.org/Confirmed",
"underName": {
"@type": "Person",
"name": "Prenom Nom"
},
"reservationFor": {
"@type": "Flight",
"flightNumber": "2739",
"airline": {"@type": "Airline","name": "IBERIA","iataCode": "IB"},
"departureAirport": {"@type": "Airport","name": "Barcelona","iataCode": "BCN"},
"departureTime": "2015-10-21T13:15:03-08:00",
"arrivalAirport": {"@type": "Airport","name": "Madrid","iataCode": "MAD"},
"arrivalTime": "2015-10-21T18:15:03-08:00"
}
} ]
</script>
You should get the following result, you'll notice the 2nd notification (Barcelona to Madrid) below it as well:
来源:https://stackoverflow.com/questions/33236320/email-markup-not-working