How to ?Global url.s="https://sepa-convertir.eu/spider/toto.xml"
HTTPRequest(#PB_HTTP_Get, url, "", @HttpGetEvent())
THanks
How to ?Global url.s="https://sepa-convertir.eu/spider/toto.xml"
HTTPRequest(#PB_HTTP_Get, url, "", @HttpGetEvent())
Just insert your domain info into the example code in the help file...loulou2522 wrote: ↑Mon Oct 04, 2021 2:43 pm I want to download n xmlfile creating on website part
How to ?Global url.s="https://sepa-convertir.eu/spider/toto.xml"
HTTPRequest(#PB_HTTP_Get, url, "", @HttpGetEvent())
THanks
Code: Select all
Procedure HttpGetEvent(Success, Result$, UserData)
If Success
Debug Result$
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
Global url.s="https://sepa-convertir.eu/spider/toto.xml"
HTTPRequest(#PB_HTTP_Get, url, "", @HttpGetEvent())
Procedure HttpGetEvent(Success, Result$, UserData)
If Success
Debug Result$
Createfile(0,"result.pdf",@toto(),#PB_Unicode)
WriteString(0,result$)
ExportFile(0, "application/pdf", #PB_localfile)
Closefile(0)
Else
Debug "HTTPRequest(): Error"
EndIf
EndProcedure
Global url.s="https://sepa-convertir.eu/spider/qrfacture.pdf"
NewMap Headers$()
Headers$("content-type") = "application/pdf;charset=Utf8"
Headers$("X-Content-Type-Options") = "nosniff"
HTTPRequest(#PB_HTTP_Get, url, "", @HttpGetEvent(),0, Headers$())
What with the domain if the code is runs as an app on an android phone ?And remember, your Spider Basic app must also run from the same Domain or it won't work for security reasons.
Code: Select all
...
download_file_name.s = "TEST.PDF"
mainURL.s = "https://www.some_domain.com/"
...
ReadFile(1, mainURL + download_file_name, @FileLoadedCallback())
...
...
Procedure FileLoadedCallback(Status, Filename$, File, SizeRead)
Select status
Case #PB_Status_Loaded
If CreateFile(1,download_file_name,@filesavedCallback(),#PB_UTF8)
While Eof(File) = #False
WriteByte(1,ReadByte(File))
Wend
CloseFile(File)
ExportFile(1,"application/pdf")
CloseFile(1)
MessageRequester("loading (" + download_file_name + ") suceeded" + #CRLF$ + "Creating (" + download_file_name + ") on disk succeeded",#PB_MessageRequester_Ok)
Else
MessageRequester("loading (" + download_file_name + ") suceeded" + #CRLF$ + "Creating (" + download_file_name + ") on disk failed",#PB_MessageRequester_Ok)
EndIf
Case #PB_Status_Error
MessageRequester("loading (" + download_file_name + ") has failed",#PB_MessageRequester_Ok)
EndSelect
EndProcedure
What with the domain if the code is runs as an app on an android phone ?And remember, your Spider Basic app must also run from the same Domain or it won't work for security reasons.
Code: Select all
...
download_file_name.s = "TEST.PDF"
mainURL.s = "https://www.some_domain.com/"
...
ReadFile(1, mainURL + download_file_name, @FileLoadedCallback())
...
...
Procedure FileLoadedCallback(Status, Filename$, File, SizeRead)
Select status
Case #PB_Status_Loaded
If CreateFile(1,download_file_name,@filesavedCallback(),#PB_UTF8)
While Eof(File) = #False
WriteByte(1,ReadByte(File))
Wend
CloseFile(File)
ExportFile(1,"application/pdf")
CloseFile(1)
MessageRequester("loading (" + download_file_name + ") suceeded" + #CRLF$ + "Creating (" + download_file_name + ") on disk succeeded",#PB_MessageRequester_Ok)
Else
MessageRequester("loading (" + download_file_name + ") suceeded" + #CRLF$ + "Creating (" + download_file_name + ") on disk failed",#PB_MessageRequester_Ok)
EndIf
Case #PB_Status_Error
MessageRequester("loading (" + download_file_name + ") has failed",#PB_MessageRequester_Ok)
EndSelect
EndProcedure
I don't think this works because the requested data is returned as a string in your HttpGetEvent procedure and saving a PDF as a string is not going to work. Williams code will work because it allows the saving as Bytes. Here is his code as a complete working example...loulou2522 wrote: ↑Tue Oct 05, 2021 8:23 am Thanks Paul that'work perfectly.
But i have a problem with PDF File the file arrive corrupt localy and can't be view. I try a lot of things but noone works here is my programm
Code: Select all
Procedure HttpGetEvent(Success, Result$, UserData) If Success Debug Result$ Createfile(0,"result.pdf",@toto(),#PB_Unicode) WriteString(0,result$) ExportFile(0, "application/pdf", #PB_localfile) Closefile(0) Else Debug "HTTPRequest(): Error" EndIf EndProcedure Global url.s="https://sepa-convertir.eu/spider/qrfacture.pdf" NewMap Headers$() Headers$("content-type") = "application/pdf;charset=Utf8" Headers$("X-Content-Type-Options") = "nosniff" HTTPRequest(#PB_HTTP_Get, url, "", @HttpGetEvent(),0, Headers$())
Code: Select all
Global download_file_name.s = "qrfacture.pdf"
mainURL.s = "https://sepa-convertir.eu/spider/"
Procedure filesavedCallback(Status, Filename$, File, SizeRead)
Select Status
Case #PB_Status_Saved
Debug "File correctly saved"
Case #PB_Status_Error
Debug "File saving has failed"
EndSelect
EndProcedure
Procedure FileLoadedCallback(Status, Filename$, File, SizeRead)
Select status
Case #PB_Status_Loaded
hFile=CreateFile(#PB_Any,download_file_name,@filesavedCallback(),#PB_UTF8|#PB_LocalFile)
If hFile
While Eof(File) = #False
WriteByte(hFile,ReadByte(File))
Wend
CloseFile(File)
ExportFile(hFile,"application/pdf",#PB_LocalFile)
CloseFile(hFile)
Debug "Load/Create succeeded"
Else
Debug "Load/Create failed"
EndIf
Case #PB_Status_Error
MessageRequester("loading (" + download_file_name + ") has failed",#PB_MessageRequester_Ok)
EndSelect
EndProcedure
ReadFile(0, mainURL + download_file_name, @FileLoadedCallback())
Code: Select all
url.s="https://sepa-convertir.eu/spider/qrfacture.pdf"
! downloads.open(v_url);
Hi, would you mind to tell us which? I have the very same problem and looking for alternatives. Thanks!due to the extreme lack of features and functionality in SpiderBasic for Mobile devices, I use a different platform for developing Mobile Apps