Question

VPS Server on OVH fail 403 Forbbiden when use the Soundcloud Api, help

  • 9 February 2016
  • 4 replies
  • 128 views

I use like that

<?php
if(isset($_POST['keyword']) && !empty($_POST['keyword']))
{

$key = strip_tags(trim($_POST['keyword']));
$api_url = 'http://api.soundcloud.com/tracks.json?client_id=xxxxxxxx&q=xxxxx;
$api_content = file_get_contents($api_url);
if (!$api_content) {
exit();
}

$api_content_array = json_decode($api_content, true);

foreach ($api_content_array as $val) { ?>
<div class="videos" id="sc-<?php echo $val['id'];?>">
<div class="expand-video"> <a class="soundcloud" id="<?php echo $val['id'];?>" href="<?php echo $val['uri'];?>"><span></span> <img src="<?php echo $val['user']['avatar_url'];?>" width="120" height="90" title="Play" alt="Play"/> </a> </div>
<div class="details">
<h6><?php echo $val['title'];?></h6>
<p class="link"><?php echo $val['user']['username'];?></p>
<p class="desc"><?php echo $val['description'];?></p>
</div>
</div>
<?php
}

}
?>

but fail file_get_contents($api_url); only on soundcloud

because i use that on api youtube and others and its ok, only with Soundcloud fail

4 replies

Userlevel 7
Badge +2
Hi,

For API related questions please head over here.

-Gina
I know very well that link you gave me, if I have written here it is because it's my last chance to fix what is wrong with me. I dont have problem with programation because i use the code on other server and its ok, the problem is other thing
Frank, I have the same problem. I think Soundcloud blacklists OVH IP ranges. I tried on many IPs from OVH and got 403s, exact same request from Digital Ocean or other IPs, no problem.
I solve the problem usung only javascript

Reply