Skip to content
Browse files

Added support for accessing public resources.

  • Loading branch information...
1 parent 3396c97 commit 2eb1294bfa32e04ed7552a57c1356b8276b8b7de @mptre committed Apr 6, 2011
Showing with 18 additions and 1 deletion.
  1. +5 −1 Services/Soundcloud.php
  2. +13 −0 tests/Soundcloud_Test.php
View
6 Services/Soundcloud.php
@@ -702,8 +702,12 @@ protected function _buildDefaultHeaders($includeAccessToken = true)
*
* @access protected
*/
- protected function _buildUrl($path, $params = null, $includeVersion = true)
+ protected function _buildUrl($path, $params = array(), $includeVersion = true)
{
+ if (!$this->_accessToken) {
+ $params['consumer_key'] = $this->_clientId;
+ }
+
if (preg_match('/^https?\:\/\//', $path)) {
$url = $path;
} else {
View
13 tests/Soundcloud_Test.php
@@ -11,6 +11,8 @@ function setUp() {
'1337',
'http://soundcloud.local/callback'
);
+
+ $this->soundcloud->setAccessToken('1337');
}
function tearDown() {
@@ -189,6 +191,8 @@ function testResponseCodeServerError() {
}
function testBuildDefaultHeaders() {
+ $this->soundcloud->setAccessToken(null);
+
self::assertEquals(
array('Accept: application/json'),
$this->soundcloud->buildDefaultHeaders()
@@ -252,6 +256,15 @@ function testBuildUrlWithAbsoluteUrl() {
);
}
+ function testBuildUrlWithoutAccessToken() {
+ $this->soundcloud->setAccessToken(null);
+
+ self::assertEquals(
+ 'https://api.soundcloud.com/v1/tracks?consumer_key=1337',
+ $this->soundcloud->buildUrl('tracks')
+ );
+ }
+
/**
* @dataProvider dataProviderHttpHeaders
*/

0 comments on commit 2eb1294

Please sign in to comment.
Something went wrong with that request. Please try again.