Skip to content

Commit 2eb1294

Browse files
author
Anton Lindqvist
committed
Added support for accessing public resources.
1 parent 3396c97 commit 2eb1294

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

Services/Soundcloud.php

+5-1
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,12 @@ protected function _buildDefaultHeaders($includeAccessToken = true)
702702
*
703703
* @access protected
704704
*/
705-
protected function _buildUrl($path, $params = null, $includeVersion = true)
705+
protected function _buildUrl($path, $params = array(), $includeVersion = true)
706706
{
707+
if (!$this->_accessToken) {
708+
$params['consumer_key'] = $this->_clientId;
709+
}
710+
707711
if (preg_match('/^https?\:\/\//', $path)) {
708712
$url = $path;
709713
} else {

tests/Soundcloud_Test.php

+13
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ function setUp() {
1111
'1337',
1212
'http://soundcloud.local/callback'
1313
);
14+
15+
$this->soundcloud->setAccessToken('1337');
1416
}
1517

1618
function tearDown() {
@@ -189,6 +191,8 @@ function testResponseCodeServerError() {
189191
}
190192

191193
function testBuildDefaultHeaders() {
194+
$this->soundcloud->setAccessToken(null);
195+
192196
self::assertEquals(
193197
array('Accept: application/json'),
194198
$this->soundcloud->buildDefaultHeaders()
@@ -252,6 +256,15 @@ function testBuildUrlWithAbsoluteUrl() {
252256
);
253257
}
254258

259+
function testBuildUrlWithoutAccessToken() {
260+
$this->soundcloud->setAccessToken(null);
261+
262+
self::assertEquals(
263+
'https://api.soundcloud.com/v1/tracks?consumer_key=1337',
264+
$this->soundcloud->buildUrl('tracks')
265+
);
266+
}
267+
255268
/**
256269
* @dataProvider dataProviderHttpHeaders
257270
*/

0 commit comments

Comments
 (0)