Soundcloud blocking cURL requests, switch to drupal_http_request?

Created on 20 September 2023, over 1 year ago

Problem/Motivation

The Soundcloud oEmbed endpoint is blocking cURL requests from Drupal. This has been an intermittent issue and is being reported by other users: https://github.com/soundcloud/api/issues/256. On Pantheon and locally with Lando, using 7.x-1.x-dev, I am getting responses like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<TITLE>ERROR: The request could not be satisfied</TITLE>
</HEAD><BODY>
<H1>403 ERROR</H1>
<H2>The request could not be satisfied.</H2>
<HR noshade size="1px">
Request blocked.
We can't connect to the server for this app or website at this time. There might be too much traffic or a configuration error. Try again later, or contact the app or website owner.
<BR clear="all">
If you provide content to customers through CloudFront, you can find steps to troubleshoot and help prevent this error by reviewing the CloudFront documentation.
<BR clear="all">
<HR noshade size="1px">
<PRE>
Generated by cloudfront (CloudFront)
Request ID: 7GHXB30gC0T6LKW9-Q55MBFYbkzi2EW7SE3M256i3N2M283C853lyw==
</PRE>
<ADDRESS>
</ADDRESS>
</BODY></HTML>

Steps to reproduce

Using current code, check the output of $soundcloud_curl_get in soundcloudfield_field_formatter_view() and see that it is returning errors like above.

Proposed resolution

For whatever reason, changing soundcloud_curl_get() to use drupal_http_request() fixes the issue.

πŸ› Bug report
Status

Active

Version

1.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States vinmassaro

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @vinmassaro
  • Status changed to Needs review over 1 year ago
  • πŸ‡ΊπŸ‡ΈUnited States vinmassaro

    Here is an MR that replaces soundcloudfield_curl_get() with soundcloudfield_request() and uses drupal_http_request(). I removed all of the proxy behavior because I believe drupal_http_request() handles this automatically if the variables are set.

    Prior to this change, embeds were not appearing on the page for me. After this MR, I can again see an embed, but it is broken with the error "You have not provided a valid SoundCloud URL." This is a new issue where the markup transformations happening in soundcloudfield_field_formatter_view() seem to be sending the wrong $url parameter to the embed and the issue impacts 7.x and 2.0.x. I will open a separate issue for this.

    Thank you!

  • Status changed to Closed: outdated 3 months ago
  • πŸ‡¦πŸ‡ΊAustralia akoepke
Production build 0.71.5 2024