[Gambas-user] Request for advice
dovey.john at gmail.com
Mon Jul 12 19:25:33 CEST 2021
I am working on wrapping theTelegram bot API in Gambas (as recommended
here before) but I'm not sure of a few things in the best approach.
For example, the simplest call to the API is to get info about the
bot. This looks like this:
public Token as string = "xxx"
Public apiURL As String = "https://api.telegram.org/bot" & Token & "/"
Public hClient As HttpClient
Public sBuffer As String
Public cmdResponse As String
Public cmdJSON As Collection
Public Sub Main()
Public Sub getBotMe()
hClient = New HttpClient As "hClient"
hClient.URL = apiURL & "getMe"
hClient.Async = False
hClient.Timeout = 60
If hClient.Status < 0 Then
' Success - read the data
If Lof(hClient) Then sBuffer = Read #hClient, Lof(hClient)
cmdResponse = sBuffer
cmdJSON = JSON.Decode(cmdResponse)
botMe = cmdJSON["result"]
Some of the questions I have include:
- does this make sense as a way to do this?
- What is the best way to store the returned collection? I thought
about usingSTRUCT, but there is a prettyheavy warning in the wiki not
to do so.
The BotMe info is in the attached image:
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 14974 bytes
Desc: not available
More information about the User