我的应用程序中的SoundCloud API存在问题。 我已经创建了一个应用程序,获取了该曲目的链接(例如http://api.soundcloud.com/tracks/48760960)并获取了stream_url,稍后可以使用SCAudioStream播放。没有用户的身份验证,我只使用我的应用程序的客户端ID和客户端密码。应用已注册。注册应用程序的SoundCloud API和401错误
创建soundCloudManager这样:
- (id)init
{
if(self = [super init])
{
conf = [SCSoundCloudAPIConfiguration configurationForProductionWithClientID: kSCClientID
clientSecret: kSCClientSecret
redirectURL: kSCRedirectURL];
conf.accessTokenURL = kSCAccessTokenURL;
api = [[SCSoundCloudAPI alloc] initWithDelegate: self
authenticationDelegate: self
apiConfiguration: conf];
//[api checkAuthentication];
}
return self;
}
如果取消注释[API checkAuthentication],然后日志将在下说:
“权威性准备与网址:https://soundcloud.com/connect? CLIENT_ID = & REDIRECT_URI = & RESPONSE_TYPE =代码”
然后我把这个方法从轨道获取数据:
- (void)runSearchingStreamWithTrackID: (NSString *)trackID
{
[api performMethod: @"GET"
onResource: @"tracks"
withParameters: [NSDictionary dictionaryWithObject:trackID forKey:@"ids"]
context: @"trackid"
userInfo: nil];
}
个
,然后将该委托的方法调用:
- (void)soundCloudAPI:(SCSoundCloudAPI *)soundCloudAPI
didFailWithError:(NSError *)error
context:(id)context
userInfo:(id)userInfo
错误的文字:
“HTTP错误:401”。
这意味着未经授权。但为什么?我是否应该被授权为soundCloud用户才能获取有关曲目的信息?
我用这对SoundCloudAPI: https://github.com/soundcloud/cocoa-api-wrapper
请帮助! 。:(
今天我固定它,我只是添加这个方法来初始化:
[api authenticateWithUsername:kLogin password:kPwd];
它经过这种方法被称为:
- (void)soundCloudAPIDidAuthenticate
所以,这个测试帐号授权。
然后我把这个方法:
- (void)runSearchingStreamWithTrackID: (NSString *)trackID
{
[api performMethod: @"GET"
onResource: @"tracks"
withParameters: [NSDictionary dictionaryWithObject:trackID forKey:@"ids"]
context: @"trackid"
userInfo: nil];
}
而且这些方法没有人会叫:
- (void)soundCloudAPI:(SCSoundCloudAPI *)soundCloudAPI
didFailWithError:(NSError *)error
context:(id)context
userInfo:(id)userInfo;
- (void)soundCloudAPI:(SCSoundCloudAPI *)soundCloudAPI
didFinishWithData:(NSData *)data
context:(id)context
userInfo:(id)userInfo;
- (void)soundCloudAPIDidAuthenticate;
- (void)soundCloudAPIDidResetAuthentication;
- (void)soundCloudAPIDidFailToGetAccessTokenWithError:(NSError *)error;
- (void)soundCloudAPIPreparedAuthorizationURL:(NSURL *)authorizationURL;
但有日志:
-[NXOAuth2PostBodyStream open] Stream has been reopened after close
而且这种方法被称为:
[NXOAuth2Client oauthConnection:connection didFailWithError:error];
error: HTTP 401
什么我错误?
现在我正在尝试实现CocoaSoundCloudAPI,它提示了我。 我的确从文档的所有步骤,但也面临着这样的错误: 自动引用计数: 没有已知的类方法的选择“JSONObjectWithData:选项:错误:” 我试图禁用的弧线,但它并没有帮助。 –
固定。 Thaks,Stigi。 –