Problem/Motivation

The oEmbed endpoint now returns JSON as the default response instead of XML. Existing code is relying on an XML response so embeds are broken.

Steps to reproduce

View an existing Soundcloudfield embed OR create a new Soundcloudfield and add a URL to a track or set. When the node is viewed, nothing appears. Watchdog will log errors related to SimpleXML not being able to parse.

Proposed resolution

Change to Json::decode (D8) and drupal_json_decode() (D7) with now default JSON oEmbed response from Soundcloud, replacing simplexml_load_string().

CommentFileSizeAuthor
#5 3199360-D7.patch1.59 KBvinmassaro
#12 3199360-D7-2.patch1.87 KBvinmassaro
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

vinmassaro created an issue. See original summary.

vinmassaro’s picture

Issue summary: View changes
vinmassaro’s picture

Issue summary: View changes

vinmassaro’s picture

Status: Active » Needs review
Issue tags: +Needs backport to D7
StatusFileSize
new1.59 KB

D8 patch file here for testing: https://git.drupalcode.org/project/soundcloudfield/-/merge_requests/1.patch

D7 patch attached.

vinmassaro’s picture

These patches require the patches from #3075203: Embed stopped working, update oembed URL to https:// also be applied to totally fix the Soundcloud oEmbed calls.

wlofgren’s picture

Your patch works great for Drupal 7.

akoepke’s picture

Thanks for this patch! We use this module on D7 and just noticed that all of our embeds were broken.

Frustrating when companies decide to make breaking changes like this.

vinmassaro’s picture

Frustrating when companies decide to make breaking changes like this.

To be fair, it looks like this was a really old change: https://developers.soundcloud.com/blog/xml-responses-deprecated

The API request in this module does not specify a format parameter so it seems this has worked for a really long time but should have broken in 2014.

wlofgren’s picture

I just applied this patch a couple days ago, but now it isn't working. It appears that oEmbed is using xml again because I reverted the patch and the module works again.

vinmassaro’s picture

Well that's obnoxious. I'm going to update both patches shortly to pass the format parameter since it appears XML is no longer officially supported.

vinmassaro’s picture

StatusFileSize
new1.87 KB

Updated D7 and D8 patch now enforce format=json in the API request.

schillerm’s picture

Hi, I've just tested the latest D7 and D8 patches (on new sites with related patches in #6 installed). Both are working fine.

  • vinmassaro authored e35dcec on 7.x-1.x
    Issue #3199360 by vinmassaro: Soundcloud oEmbed endpoint now defaulting...

  • vinmassaro committed 2f4b2cc on 8.x-1.x
    Issue #3199360: Soundcloud oEmbed endpoint now defaulting to JSON...
  • attila.fekete committed 82e0d11 on 8.x-1.x
    Merge branch 'issue/soundcloudfield-3199360-3199360-soundcloud-oembed-...
attila.fekete’s picture

Status: Needs review » Fixed

Thank you @vinmassaro and others for pushing this through. Released 8.x-1.0-alpha2 and 7.x-1.5, both include this fix.

vinmassaro’s picture

@attila.fekete Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.