Hola a todos.
Le he preguntado a Mistral que me diera un código en Gambas para poder acceder al calendario de una instancia de NextCloud y me ha soltado esto:
Código:
' Gambas class file
Public Sub Main()
Dim sUrl As String
Dim sUser As String
Dim sPassword As String
Dim sCalendar As String
Dim hClient As HttpClient
Dim sResponse As String
' Configuración
sUrl = "https://tunexcloud.com/remote.php/dav/calendars/"
sUser = "tu_usuario"
sPassword = "tu_contraseña"
sCalendar = "nombre_del_calendario"
' Crear cliente HTTP
hClient = New HttpClient
' Configurar autenticación básica
hClient.Username = sUser
hClient.Password = sPassword
' Realizar solicitud GET
Try sResponse = hClient.Get(sUrl & sUser & "/" & sCalendar & "/?export")
' Procesar la respuesta (aquí deberías parsear el contenido del calendario)
Print sResponse
Catch
Print "Error al acceder al calendario"
End
End
Veo el código muchas cosas mal, y no tengo ni idea de como se usa. ¿Alguien en la sala que me oriente?
Muchas gracias.
He avanzado un poco mirando el ejemplo desde la ayuda de Gambas y no tiene nada que ver con lo mostrado por la IA:
https://gambaswiki.org/wiki/comp/gb.net.curl/httpclient
y me ha quedado algo así:
Código:
Dim hClient as HttpClient
Dim sResponse as String
hClient = new HttpClient as "hClient"
hclient.URL= "dirección del calendario"
hClient.User = "usuario"
hClient.Password = "contraseña"
hClient.Auth = Net.AuthBasic
hClient.Async = False
hClient.Timeout = 60
hClient.Get()
Print "Begin"
if hClient.Status < 0 Then
Print "ERROR"
Else
If Lof(hClient) then sResponse = Read #hClient, Lof(hClient)
print sReponse
EndIf
Esto aparentemente funciona pero el servidor me dice esto:
Cita:This is the WebDAV interface. It can only be accessed by WebDAV clients such as the Nextcloud desktop sync client
¿Quiere decir que no puedo acceder a mi calendario?
Un saludo.