THERE HAS BEEN AN ERROR WITH THE APPLE NEWS API: INVALID_DOCUMENT
-
Dear Support,
We we are unable to submit articles to Apple News using your plugin, for a few weeks now.
The error message we are getting is:
THERE HAS BEEN AN ERROR WITH THE APPLE NEWS API: INVALID_DOCUMENT – ‘TEXT’ PROPERTY IS NOT VALID AND WELL-FORMED HTML. SEE OFFSET=218/LINE=2/COLUMN=191. (KEYPATH COMPONENTS->18)
Is there anything we could do to fix this?
Thanks,
Mihai
-
You’ll have to download your article JSON for the article that is failing by going to Apple News > Articles in the WordPress admin, finding the article, and clicking the Download link. You can then open the JSON file and look at the 19th item (because arrays are zero-indexed, so components->0 is the first item, and components->18 is the 19th item) in the root-level “components” item (running the JSON through an auto-formatter will help with this) and looking at the contents. The error message is saying that the HTML is invalid, so you’ll have to figure out what about the HTML is invalid, and where that’s coming from. If it’s something you can identify in your content and fix, that’s great. If it’s something that’s being written by this plugin, please provide the link to the article that’s failing, the paragraph or item that is causing the failure, and I will attempt to reproduce the issue.
Hi Kevin,
Thanks for your feedback!
The error occurs with any article and it all started a few months. May it be related to the PHP version?
After failing to publish say the latest article with this error message:
“There has been an error with the Apple News API: INVALID_DOCUMENT – ‘text’ property is not valid and well-formed HTML. See offset=259/line=2/column=238. (keyPath components->11)”
I’ve downloaded its JSON, which is:
“
{"version":"1.11","identifier":"post-251016","language":"en-GB","title":"ShinyShiny snippets: Apple nudity-blurring feature to come to UK","documentStyle":{"backgroundColor":"#e5feff"},"layout":{"columns":7,"width":1024,"margin":100,"gutter":20},"components":[{"role":"title","text":"ShinyShiny snippets: Apple nudity-blurring feature to come to UK","format":"html","textStyle":"default-title","layout":"title-layout"},{"role":"byline","text":"April 22, 2022 | by Chris Price","format":"html","textStyle":"default-byline","layout":"byline-layout"},{"role":"photo","URL":"https:\/\/i0.wp.com\/www.techdigest.tv\/wp-content\/uploads\/2022\/04\/apple-nudity-blurring-1024x628.png?resize=819%2C503&ssl=1","layout":"full-width-image"},{"role":"body","text":"<p><br \/>\nApple\u2019s \u201c<a href=\"https:\/\/support.apple.com\/en-us\/HT212850\">communication safety in Messages<\/a>\u201d feature, which is designed to automatically blur images containing nudity sent to children using the company\u2019s messaging service, is now rolling out to additional countries. After <a href=\"https:\/\/www.theverge.com\/2021\/12\/13\/22828226\/apple-ios-15-2-iphone-update-digital-legacy-music-macro-app-privacy\">launching in the US last year<\/a>, the feature is now coming to the Messages apps on iOS, iPadOS, and macOS for users in the UK, Canada, New Zealand, and Australia. Exact timing is unclear, but <a href=\"https:\/\/www.theguardian.com\/technology\/2022\/apr\/20\/apple-says-new-child-safety-feature-to-be-rolled-out-for-uk-iphones\"><em>The Guardian <\/em>reports<\/a> that the feature is coming to the UK \u201csoon.\u201d Scanning happens on the device and does not impact the end-to-end encryption of messages. Instructions on how to enable the feature, which is integrated with Apple\u2019s existing Family Sharing system, can be found <a href=\"https:\/\/support.apple.com\/en-us\/HT212850\">here<\/a>. <a href=\"https:\/\/www.theverge.com\/2022\/4\/21\/23035183\/ios-messages-communication-safety-nudity-sexually-explicit-message-blurring\">The Verge<\/a> <\/p>","format":"html","textStyle":"dropcapBodyStyle","layout":"body-layout"},{"role":"body","text":"<p>Members of the European Parliament this week voted overwhelmingly in support of legislation that will compel Apple to offer a USB-C port on all iPhones, iPads, and <strong>AirPods<\/strong> in Europe.<\/p>","format":"html","textStyle":"default-body","layout":"body-layout"},{"role":"photo","URL":"https:\/\/i0.wp.com\/images.macrumors.com\/t\/p6SRpXFyzxvLIaxRQetVqy8NTLE=\/400x0\/article-new\/2021\/09\/USB-C-Over-Lightning-Feature.jpg?resize=779%2C439&ssl=1","layout":"full-width-image"},{"role":"body","text":"<p><br \/>\nThe proposal, known as a directive, will force all consumer electronics manufacturers who sell devices in Europe to ensure that all new phones, tablets, laptops, digital cameras, headphones, headsets, handheld videogame consoles, and portable speakers feature a USB-C port, regardless of the manufacturer. Exemptions will only apply for devices that are too small to offer a <strong>USB-C port<\/strong>, such as smart watches, health trackers, and some sports equipment. This \u201ccommon port\u201d would be a world first and impact Apple in particular since it widely uses the Lightning connector instead of USB-C on many of its devices. <a href=\"https:\/\/www.macrumors.com\/2022\/04\/21\/eu-closer-to-mandate-apple-switch-to-usb-c\/\">MacRumors<\/a><\/p>","format":"html","textStyle":"default-body","layout":"body-layout"},{"role":"body","text":"<p>Following reports earlier this week that <strong>Microsoft<\/strong> is considering introducing ads to free-to-play games on Xbox, a new report has surfaced claiming Sony has been working on its own plan to do the same with its PlayStation games. As <a href=\"https:\/\/www.businessinsider.com\/sony-plans-to-sell-advertising-in-playstation-games-2022-4\">reported by Business Insider<\/a> (paywall), which cites three people involved with Sony plans as its sources, the company is currently investigating ways to encourage developers to continue making free-to-play games \u2013 said to have soared in popularity during the pandemic \u2013 by providing new ways to monetise them.At present, PlayStation\u2019s ad inventory is said to be limited to in-menu ads \u2013 which can be used by publishers and developers to do things like promote their own games on the PlayStation Store \u2013 and ads served via streaming video on certain apps. <a href=\"https:\/\/www.eurogamer.net\/sony-reportedly-considering-putting-ads-in-free-to-play-playstation-games\">Eurogamer<\/a><\/p>","format":"html","textStyle":"default-body","layout":"body-layout"},{"role":"body","text":"<p> <a href=\"https:\/\/www.pocket-lint.com\/phones\/news\/apple\">Apple<\/a> is reportedly aiming to release a full-screen iPhone two years from now. This is according to a well-known Apple analyst. Ming-Chi Kuo, who has a solid record when it comes to predicting Apple\u2019s upcoming product roadmap, has claimed in a tweet that an iPhone with an uninterrupted display \u2013 aka a \u201cfull screen\u201d \u2013 will arrive in 2024. The full screen might be limited to high-end models of the iPhone 16, he noted. That means the iPhone 16 Pro and Max could house the front-facing camera and <a href=\"https:\/\/www.pocket-lint.com\/phones\/news\/apple\/142207-what-is-apple-face-id-and-how-does-it-work\">Face ID<\/a> under the display (the standard or mini models presumably won\u2019t). <a href=\"https:\/\/www.pocket-lint.com\/phones\/news\/apple\/160820-apple-might-release-its-first-full-screen-iphone-in-2024\">Pocket Lint<\/a><\/p>","format":"html","textStyle":"default-body","layout":"body-layout"},{"role":"tweet","URL":"https:\/\/twitter.com\/mingchikuo\/status\/1516729808893648901","layout":"tweet-layout"},{"role":"body","text":"<p>CNN\u2019s new owner says it will close the US-based news channel\u2019s streaming service just a month after it launched. Warner Bros Discovery (WBD) says it will issue refunds to subscribers after the service is shut down on 30 April. The head of CNN+ has resigned and hundreds more workers could be at risk of losing their jobs. This week, $50bn (\u00a338.4bn) was wiped off the stock market value of streaming giant Netflix after it revealed a sharp fall in subscribers. <strong>CNN+<\/strong> was launched on 29 March in an attempt to bring in revenues from news streaming subscriptions. <a href=\"https:\/\/www.bbc.co.uk\/news\/business-61185298\">BBC<\/a><\/p>","format":"html","textStyle":"default-body","layout":"body-layout"},{"role":"body","text":"<ul><li \/> \n <li><a href=\"https:\/\/facebook.com\/sharer.php?u=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&t=ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK+<+ShinyShiny\">Facebook<\/a><\/li> <li><a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&text=ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK+<+ShinyShiny\">Twitter<\/a><\/li> <li><a href=\"http:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&media=https%3A%2F%2Fwww.shinyshiny.tv%2Fwp-content%2Fuploads%2F2022%2F04%2Fapple-nudity-blurring-1024x628-1-600x368.png&description=Apple%E2%80%99s+%E2%80%9Ccommunication+safety+in+Messages%E2%80%9D+feature%2C+which+is+designed+to+automatically+blur+images+containing+nudity+sent+to+children+using+the+company%E2%80%99s+messaging+service%2C+is+now+rolling+out+to+additional+countries.+After%26nbsp%3Blaunching+in+the+US+last+year%2C+the+feature+is+now%26hellip%3B\">Pinterest<\/a><\/li> <li><a href=\"http:\/\/linkedin.com\/shareArticle?mini=true&url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&title=ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK&source=ShinyShiny&summary=Apple%E2%80%99s+%E2%80%9Ccommunication+safety+in+Messages%E2%80%9D+feature%2C+which+is+designed+to+automatically+blur+images+containing+nudity+sent+to+children+using+the+company%E2%80%99s+messaging+service%2C+is+now+rolling+out+to+additional+countries.+After%26nbsp%3Blaunching+in+the+US+last+year%2C+the+feature+is+now%26hellip%3B\">Linkedin<\/a><\/li> <li><a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html\">Google+<\/a><\/li> <li><a href=\"mailto:?subject=ShinyShiny:+ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK&body=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html\">Email<\/a><\/li> <\/ul>","format":"html","textStyle":"default-body","layout":"body-layout-last"}],"componentTextStyles":{"dropcapBodyStyle":{"textAlignment":"left","fontName":"Optima-Regular","fontSize":17,"tracking":0,"lineHeight":22,"textColor":"#000000","linkStyle":{"textColor":"#3045ca"},"paragraphSpacingBefore":18,"paragraphSpacingAfter":18,"dropCapStyle":{"numberOfLines":5,"numberOfCharacters":1,"padding":5,"fontName":"HelveticaNeue-CondensedBlack","textColor":"#000000","numberOfRaisedLines":0,"backgroundColor":"#ffff00"}},"default-body":{"textAlignment":"left","fontName":"Optima-Regular","fontSize":17,"tracking":0,"lineHeight":22,"textColor":"#000000","linkStyle":{"textColor":"#3045ca"},"paragraphSpacingBefore":18,"paragraphSpacingAfter":18},"default-title":{"backgroundColor":"#ffff00","fontName":"HelveticaNeue-CondensedBlack","fontSize":72,"lineHeight":68,"tracking":-0.03,"textColor":"#000000","textAlignment":"left","textTransform":"uppercase"},"default-byline":{"backgroundColor":"#ffff00","textAlignment":"left","fontName":"Optima-Regular","fontSize":13,"lineHeight":22,"tracking":0.21,"textColor":"#000000","textTransform":"uppercase"}},"textStyles":{"default-tag-code":{"fontName":"Menlo-Regular","fontSize":16,"tracking":0,"lineHeight":20,"textColor":"#000000"},"default-tag-pre":{"textAlignment":"left","fontName":"Menlo-Regular","fontSize":16,"tracking":0,"lineHeight":20,"textColor":"#000000","paragraphSpacingBefore":18,"paragraphSpacingAfter":18},"default-tag-samp":{"fontName":"Menlo-Regular","fontSize":16,"tracking":0,"lineHeight":20,"textColor":"#000000"}},"componentLayouts":{"full-width-image":{"margin":{"bottom":25,"top":25},"columnSpan":7,"columnStart":0},"body-layout":{"columnStart":1,"columnSpan":6,"margin":{"top":12,"bottom":12}},"body-layout-last":{"columnStart":1,"columnSpan":6,"margin":{"top":12,"bottom":30}},"tweet-layout":{"margin":{"top":30,"bottom":30},"columnStart":0,"columnSpan":7},"title-layout":{"columnSpan":6,"columnStart":1,"margin":{"top":30,"bottom":60}},"byline-layout":{"columnSpan":6,"columnStart":1,"margin":{"top":10,"bottom":10}}},"metadata":{"thumbnailURL":"https:\/\/www.shinyshiny.tv\/wp-content\/uploads\/2022\/04\/apple-nudity-blurring-1024x628-1.png","authors":["Chris Price"],"dateCreated":"2022-04-22T19:05:36+00:00","dateModified":"2022-04-22T19:06:24+00:00","datePublished":"2022-04-22T19:05:36+00:00","canonicalURL":"https:\/\/www.shinyshiny.tv\/2022\/04\/shinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html","generatorIdentifier":"publish-to-apple-news","generatorName":"Publish to Apple News","generatorVersion":"2.3.2"},"autoplacement":{"advertisement":{"bannerType":"any","distanceFromMedia":"10vh","enabled":true,"frequency":1,"layout":{"margin":15}}}}
”Then I went to:
https://jsonformatter.curiousconcept.com/And validated the JSON, so there is nothing wrong with it!
The problem occurs with any article from shinyshiny.tv and techdigest.tv.
I could also supply you FTP and WP admin access, if you need.
Grateful if we could fix this because I’m unable to publish to Apply News for a couple of months.
Thanks,
MihaiThe clue is in
keyPath components->11
. If you format that JSON, and you look at thecomponents
key at index 11 (actually the 12th item, the index starts at 0) you will see this:{ "role": "body", "text": "<ul><li \/> \n <li><a href=\"https:\/\/facebook.com\/sharer.php?u=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&t=ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK+<+ShinyShiny\">Facebook<\/a><\/li> <li><a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&text=ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK+<+ShinyShiny\">Twitter<\/a><\/li> <li><a href=\"http:\/\/pinterest.com\/pin\/create\/button\/?url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&media=https%3A%2F%2Fwww.shinyshiny.tv%2Fwp-content%2Fuploads%2F2022%2F04%2Fapple-nudity-blurring-1024x628-1-600x368.png&description=Apple%E2%80%99s+%E2%80%9Ccommunication+safety+in+Messages%E2%80%9D+feature%2C+which+is+designed+to+automatically+blur+images+containing+nudity+sent+to+children+using+the+company%E2%80%99s+messaging+service%2C+is+now+rolling+out+to+additional+countries.+After%26nbsp%3Blaunching+in+the+US+last+year%2C+the+feature+is+now%26hellip%3B\">Pinterest<\/a><\/li> <li><a href=\"http:\/\/linkedin.com\/shareArticle?mini=true&url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&title=ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK&source=ShinyShiny&summary=Apple%E2%80%99s+%E2%80%9Ccommunication+safety+in+Messages%E2%80%9D+feature%2C+which+is+designed+to+automatically+blur+images+containing+nudity+sent+to+children+using+the+company%E2%80%99s+messaging+service%2C+is+now+rolling+out+to+additional+countries.+After%26nbsp%3Blaunching+in+the+US+last+year%2C+the+feature+is+now%26hellip%3B\">Linkedin<\/a><\/li> <li><a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html\">Google+<\/a><\/li> <li><a href=\"mailto:?subject=ShinyShiny:+ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK&body=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html\">Email<\/a><\/li> <\/ul>", "format": "html", "textStyle": "default-body", "layout": "body-layout-last" }
In particular, the URL has a < character in it, which breaks the HTML, and there is an empty self-closing
<li />
at the beginning of the list. Extracting just that piece and unescaping the slashes and quotes yields this:<ul><li /><li><a href="https://facebook.com/sharer.php?u=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&t=ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK+<+ShinyShiny">Facebook</a></li> <li><a href="https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&text=ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK+<+ShinyShiny">Twitter</a></li> <li><a href="https://pinterest.com/pin/create/button/?url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&media=https%3A%2F%2Fwww.shinyshiny.tv%2Fwp-content%2Fuploads%2F2022%2F04%2Fapple-nudity-blurring-1024x628-1-600x368.png&description=Apple%E2%80%99s+%E2%80%9Ccommunication+safety+in+Messages%E2%80%9D+feature%2C+which+is+designed+to+automatically+blur+images+containing+nudity+sent+to+children+using+the+company%E2%80%99s+messaging+service%2C+is+now+rolling+out+to+additional+countries.+After%26nbsp%3Blaunching+in+the+US+last+year%2C+the+feature+is+now%26hellip%3B">Pinterest</a></li> <li><a href="https://linkedin.com/shareArticle?mini=true&url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html&title=ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK&source=ShinyShiny&summary=Apple%E2%80%99s+%E2%80%9Ccommunication+safety+in+Messages%E2%80%9D+feature%2C+which+is+designed+to+automatically+blur+images+containing+nudity+sent+to+children+using+the+company%E2%80%99s+messaging+service%2C+is+now+rolling+out+to+additional+countries.+After%26nbsp%3Blaunching+in+the+US+last+year%2C+the+feature+is+now%26hellip%3B">Linkedin</a></li> <li><a href="https://plus.google.com/share?url=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html">Google+</a></li> <li><a href="mailto:?subject=ShinyShiny:+ShinyShiny+snippets%3A+Apple+nudity-blurring+feature+to+come+to+UK&body=https%3A%2F%2Fwww.shinyshiny.tv%2F2022%2F04%2Fshinyshiny-snippets-apple-nudity-blurring-feature-to-come-to-uk.html">Email</a></li> </ul>
Running this HTML through an HTML validator yields three errors, one related to the self-closing LI tag, the other two related to the unescaped < characters in the URLs.
So the original error message from Apple gives you all of the information you need here – it tells you the location in the JSON that contains malformed HTML, and you need to fix the HTML so that it isn’t malformed. Ideally, you wouldn’t include the social sharing code in what you are sending to Apple at all, but at a minimum, the bugs with the HTML it is creating need to be fixed.
Hi, Kevin!
Thank you so much for further detailing it!
After doing some research I’ve discovered that the problem was caused by the plugin called “QuickShare”. Disabling it solved the problem.
I might spend some time debugging it…
Thanks,
Mihai
- The topic ‘THERE HAS BEEN AN ERROR WITH THE APPLE NEWS API: INVALID_DOCUMENT’ is closed to new replies.