(Objective-C) VoiceBase -- Retrieve Plain Text Transcript
Retrieves a plain text transcript for a media file.
#import <NSString.h>
#import <CkoHttp.h>
#import <CkoStringBuilder.h>
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Insert your Bearer token here:
NSString *accessToken = @"VOICEBASE_TOKEN";
CkoHttp *http = [[CkoHttp alloc] init];
// Add the access (bearer) token to the request, which is a header
// having the following format:
// Authorization: Bearer <userAccessToken>
CkoStringBuilder *sbAuth = [[CkoStringBuilder alloc] init];
[sbAuth Append: @"Bearer "];
[sbAuth Append: accessToken];
[http SetRequestHeader: @"Authorization" value: [sbAuth GetAsString]];
CkoStringBuilder *sbUrl = [[CkoStringBuilder alloc] init];
[sbUrl Append: @"https://apis.voicebase.com/v2-beta/media/$MEDIA_ID/transcripts/latest"];
int replaceCount = [[sbUrl Replace: @"$MEDIA_ID" replacement: @"f9b9bb88-d52c-4960-bcef-d516a9f85594"] intValue];
http.Accept = @"text/plain";
NSString *strText = [http QuickGetStr: [sbUrl GetAsString]];
if (http.LastMethodSuccess != YES) {
NSLog(@"%@",http.LastErrorText);
return;
}
NSLog(@"%@%d",@"Response status code = ",[http.LastStatus intValue]);
NSLog(@"%@",strText);
if ([http.LastStatus intValue] != 200) {
NSLog(@"%@",@"Failed");
}
else {
NSLog(@"%@",@"Success");
}
|