DataFlex
DataFlex
VoiceBase -- Retrieve Plain Text Transcript
See more VoiceBase Examples
Retrieves a plain text transcript for a media file.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
String sAccessToken
Handle hoHttp
Handle hoSbAuth
Boolean iSuccess
Handle hoSbUrl
Integer iReplaceCount
String sStrText
String sTemp1
Integer iTemp1
Boolean bTemp1
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Insert your Bearer token here:
Move "VOICEBASE_TOKEN" To sAccessToken
Get Create (RefClass(cComChilkatHttp)) To hoHttp
If (Not(IsComObjectCreated(hoHttp))) Begin
Send CreateComObject of hoHttp
End
// Add the access (bearer) token to the request, which is a header
// having the following format:
// Authorization: Bearer <userAccessToken>
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbAuth
If (Not(IsComObjectCreated(hoSbAuth))) Begin
Send CreateComObject of hoSbAuth
End
Get ComAppend Of hoSbAuth "Bearer " To iSuccess
Get ComAppend Of hoSbAuth sAccessToken To iSuccess
Get ComGetAsString Of hoSbAuth To sTemp1
Send ComSetRequestHeader To hoHttp "Authorization" sTemp1
Get Create (RefClass(cComChilkatStringBuilder)) To hoSbUrl
If (Not(IsComObjectCreated(hoSbUrl))) Begin
Send CreateComObject of hoSbUrl
End
Get ComAppend Of hoSbUrl "https://apis.voicebase.com/v2-beta/media/$MEDIA_ID/transcripts/latest" To iSuccess
Get ComReplace Of hoSbUrl "$MEDIA_ID" "f9b9bb88-d52c-4960-bcef-d516a9f85594" To iReplaceCount
Set ComAccept Of hoHttp To "text/plain"
Get ComGetAsString Of hoSbUrl To sTemp1
Get ComQuickGetStr Of hoHttp sTemp1 To sStrText
Get ComLastMethodSuccess Of hoHttp To bTemp1
If (bTemp1 <> True) Begin
Get ComLastErrorText Of hoHttp To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComLastStatus Of hoHttp To iTemp1
Showln "Response status code = " iTemp1
Showln sStrText
Get ComLastStatus Of hoHttp To iTemp1
If (iTemp1 <> 200) Begin
Showln "Failed"
End
Else Begin
Showln "Success"
End
End_Procedure