Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8655223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T14:58:33+00:00 2026-06-12T14:58:33+00:00

I am trying to render a SoundCloud HTML5 widget using the PHP API, but

  • 0

I am trying to render a SoundCloud HTML5 widget using the PHP API, but every time I run the command I think should return the HTML for the widget, I simply get an Exception:

The requested URL responded with HTTP code 302

I realise this is a redirect. What I don’t know is why that’s all I ever get, or what to do about it to actually get the widget HTML.

The documentation on the API says that to embed the widget using PHP you should do this:

<?php
    require_once 'Services/Soundcloud.php';

    // create a client object with your app credentials
    $client = new Services_Soundcloud('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');

    // get a tracks oembed data
    $track_url = 'http://soundcloud.com/forss/flickermood';
    $embed_info = $client->get('/oembed', array('url' => $track_url));

    // render the html for the player widget
    print $embed_info['html'];

I’m running this:

// NB: Fully authorised SoundCloud API instance all working prior to this line
// $this->api refers to an authorised instance of Services_Soundcloud

try {   
        $widget = array_pop(
            json_decode( $this->api->get('oembed', array('url' => $track_url)) )
        );

        print_r($widget);

    } catch (Exception $e)
    {
        print_r($e->getMessage());
    }

where “track_url” is actually the URL I get back when asking SoundCloud for a track object earlier in the app using the same API.

I’m not actually sure this URL is correct in the first place, because the track object I get back gives the ‘uri’ in the form:

[uri] => https://api.soundcloud.com/tracks/62556508

The documentation examples all have a straight http://soundcloud.com/username/track-permalink URL – but even using a known path to a public track the attempt to run the API oembed method fails… I still get a 302 Exception.

Finally, there are mentions of setting “allow_redirects” to false in the ‘get’ command, but this has no effect when I add to the parameters used to build the query to the API. I also tried adding additional cURL options, but that too had no effect.

I have definitely enabled API access to the track within SoundCloud.

Kind of banging my head off the wall on this. If anyone has any pointers I’d be very grateful to hear them. Just for clarity’s sake, I am able to access all the user data, comments etc. via the API instance I have created, so it appears to be working fine.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T14:58:34+00:00Added an answer on June 12, 2026 at 2:58 pm

    Thanks for pointing this out. There was a bug in the documentation that lead you astray. Sorry about that. I’ve updated the docs to fix the bug. Here’s the updated code sample:

    <?php
    
    require_once 'Services/Soundcloud.php';
    
    // create a client object with your app credentials
    $client = new Services_Soundcloud('YOUR_CLIENT_ID', 'YOUR_CLIENT_SECRET');
    $client->setCurlOptions(array(CURLOPT_FOLLOWLOCATION => 1));
    
    // get a tracks oembed data
    $track_url = 'http://soundcloud.com/forss/flickermood';
    $embed_info = json_decode($client->get('oembed', array('url' => $track_url)));
    
    // render the html for the player widget
    print $embed_info->html;
    

    Note the differences:

    • You need to set CURLOPT_FOLLOWLOCATION to 1 as mentioned in the comments above.
    • You need to wrap the return from $client->get in json_decode
    • The result is an stdClass object, not an Array and so the html property has to be accessed using the -> operator.

    Hope that helps. Feel free to comment in case you’re still having problems and I’ll amend my answer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to render a square, using GL_QUADS, but every time it renders
I'm trying to render images with verdana text using PHP imagettftext function. However, all
I am trying to render a float value using NSNumberFormatter's SpellOutStyle, but the results
I'm trying to render a pretty simple data structure using RABL, but I can't
I'm trying to render some text using PIL, but the result that comes out
i´m trying to render PDF with renderpdf grails plugin, but their documentation is very
I've been trying to render a webpage using the Adobe Flex / Flash builder
I am trying to render the magento contact form into a .phtml file, but
I'm trying to render a bit of text using Core Graphics APIs and I'm
So i'm trying to render a template with trimpath in IE8, but when passing

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.