2017-01-20 7 views
0

Twilioアカウントに関連付けられたすべての録音オブジェクトをダウンロードしようとしていますが、これを達成するTwilioVoiceClient.hまたはVoiceClient.hのメソッドは表示されません。私はProgramableVoice iOS SDK(ベータ5)を使用していますが、オンラインドキュメントには目的を表示していません。私は録音SIDがそうのように知られていれば問題なく個々の録画を再生することができるよ。私もやってみたい何プログラム可能な音声SDKを使用したTwilioのすべての録音の取得

NSString *baseString = @"https://api.twilio.com/2010-04-01/Accounts/"; 
NSString *recordingSID = @"RExxxxxxxxxxxxxxxxxxxxxxxxxxxxx";  
NSURL *recordingUrl = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@/Recordings/%@.mp3", baseString, kTwilAccount, recordingSID]]; 
avPlayer = [[AVPlayer alloc]initWithURL:recordingUrl]; 

は、アカウントに関連付けられたすべての記録オブジェクトをダウンロードしています。このために、私はNSUrlConnectionになってきました:

NSString *baseStr = [NSString stringWithFormat:@"https://api.twilio.com/2010-04-01/Accounts/%@/Recordings.json", kTwilAccount]; 
NSURL *url = [NSURL URLWithString:baseStr]; 
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:1000.0]; 
NSString *authStr = [NSString stringWithFormat:@"%@:%@", kTwilAccount, authToken]; 
NSData *authData = [authStr dataUsingEncoding:NSASCIIStringEncoding]; 
NSString *authValue = [NSString stringWithFormat:@"Base %@", [authData base64EncodedStringWithOptions:NSDataBase64Encoding64CharacterLineLength]]; 
[theRequest setValue:authValue forHTTPHeaderField:@"Authorization"]; 

[NSURLConnection sendAsynchronousRequest:theRequest queue:[NSOperationQueue mainQueue] completionHandler:^(NSURLResponse *responseCode, NSData *responseData, NSError *responseError) { 
    if ([responseData length] > 0 && responseError == nil){ 
     // do work 
    } else if ([responseData length] == 0 && responseError == nil){ 
     NSLog(@"data error: %@", responseError); 

    } else if (responseError != nil && responseError.code == NSURLErrorTimedOut){ 
     NSLog(@"data timeout: %ld", (long)NSURLErrorTimedOut); 


    } else if (responseError != nil){ 
     NSLog(@"data download error: %@", responseError); 


    } 
}]; 

これは、コンソール出力でダウンロードエラーが発生:

データダウンロードエラー:エラードメイン= NSURLErrorDomainコード= -1012 "(ヌル)" のUserInfo = {NSErrorFailingURLStringKey = https://api.twilio.com/2010-04-01/Accounts/ACdee27262ef5fd27a593a697d80e7f7b0/Recordings.json、NSUnderlyingError = 0x17084aa70 {エラードメイン= kCFErrorDomainCFNetworkコード= -1012 "(ヌル)" のUserInfo = {_ kCFURLErrorAuthFailedResponseKey = {URL = https://api.twilio.com/2010-04-01/Accounts/ACdeedkfdjieireijrekjrkejrk4kj4/Recordings.json}}}、NSErrorFailingURLKey = https://api.twilio.com/2010-04-01/Accounts/ACdeedkfdjieireijrekjrkejrk4kj4/Recordings.json}明らか

、それがありませんかエンドポイントを認識するかどうか私が認証しているのと同じように。どのように私は客観的にこの情報を要求する必要がありますか?

読んでいただきありがとうございます。

答えて

1

ここではTwilioの開発者エバンジェリストです。

実際には、アカウント情報をアプリケーションに入れて、アプリケーションからAPI呼び出しを行うことはお勧めしません。悪意のある攻撃者がアプリケーションを逆コンパイルし、資格情報を取得し、アカウントを乱用する可能性があります。

代わりにサーバー側のソリューションを実装して、APIを呼び出して録画を取得することをお勧めします。その後、アプリケーションからサーバーと通信できます。

Here's a blog post that explains more and includes an example for sending an SMS from an iOS application.

関連する問題