Xbase++
Xbase++
VoiceBase -- Retrieve Plain Text Transcript
See more VoiceBase Examples
Retrieves a plain text transcript for a media file.Chilkat Xbase++ Downloads
LOCAL cAccessToken
LOCAL oHttp
LOCAL oSbAuth
LOCAL oSbUrl
LOCAL nReplaceCount
LOCAL cStrText
// This example assumes the Chilkat HTTP API to have been previously unlocked.
// See Global Unlock Sample for sample code.
// Insert your Bearer token here:
cAccessToken := "VOICEBASE_TOKEN"
oHttp := CreateObject("Chilkat.Http")
// Add the access (bearer) token to the request, which is a header
// having the following format:
// Authorization: Bearer <userAccessToken>
oSbAuth := CreateObject("Chilkat.StringBuilder")
oSbAuth:Append("Bearer ")
oSbAuth:Append(cAccessToken)
oHttp:SetRequestHeader("Authorization", oSbAuth:GetAsString())
oSbUrl := CreateObject("Chilkat.StringBuilder")
oSbUrl:Append("https://apis.voicebase.com/v2-beta/media/$MEDIA_ID/transcripts/latest")
nReplaceCount := oSbUrl:Replace("$MEDIA_ID", "f9b9bb88-d52c-4960-bcef-d516a9f85594")
oHttp:Accept := "text/plain"
cStrText := oHttp:QuickGetStr(oSbUrl:GetAsString())
IF (oHttp:LastMethodSuccess != 1)
? oHttp:LastErrorText
oHttp:destroy()
oSbAuth:destroy()
oSbUrl:destroy()
RETURN
ENDIF
? "Response status code = " + Str(oHttp:LastStatus)
? cStrText
IF (oHttp:LastStatus != 200)
? "Failed"
ELSE
? "Success"
ENDIF
oHttp:destroy()
oSbAuth:destroy()
oSbUrl:destroy()