アプリケーションの SoundCloud API に問題があります。トラックへのリンクを取得するアプリを作成し (たとえば、このhttp://api.soundcloud.com/tracks/48760960のようなもの)、後で SCAudioStream を使用して再生できる stream_url を取得します。ユーザーの認証はありません。アプリのクライアント ID とクライアント シークレットのみを使用します。アプリが登録されました。
私はこの方法で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] のコメントを外すと、ログに次のように表示されます。
「認証準備完了 URL:https://soundcloud.com/connect?client_id=&redirect_uri=&response_type=code」
次に、このメソッドを呼び出してトラックからデータを取得します。
- (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
助けてください!:(
今日、私はそれを修正しました。このメソッドを init に追加するだけです:
[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
私は何を間違っていますか?