HTTPRequest

Just starting out? Need help? Post your questions and find answers here.
thanos
Posts: 5
Joined: Sat Apr 15, 2017 3:44 pm

HTTPRequest

Post by thanos »

Hello.
I tried to run the HTTRequest example. SpiderBasic 2.40

Code: Select all

Procedure HttpGetEvent(Success, Result$, UserData)
  If Success
    Debug Result$
  Else
    Debug "HTTPRequest(): Error"
  EndIf
EndProcedure

; Get the content of this file, and display it in the debug window
;
HTTPRequest(#PB_HTTP_Get, "https://www.adouros.gr/projects/papertrade/pelates.php",  "", @HttpGetEvent())
;HTTPRequest(#PB_HTTP_Get, "https://www.adouros.gr/projects/papertrade/log_file.txt", "", @HttpGetEvent())
Both files, are existed and took results if I put the URL$ in a browse window.
I just received "HTTPRequest(): Error"
What am I missing?
Regards.
User avatar
Peter
Posts: 1086
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1:9080
Contact:

Re: HTTPRequest

Post by Peter »

If you look at the output in the Developer Console of your browser, you will see the following:
Access to XMLHttpRequest at 'https://www.adouros.gr/projects/papertr ... 0976679930' from origin 'http://127.0.0.1:9080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I.e., for security reasons, access to a resource of another address has been denied.

If you own the web server that runs this php file, then you can allow CORS access. If not, then you only have the diversions via a component that is located on your web server.
thanos
Posts: 5
Joined: Sat Apr 15, 2017 3:44 pm

Re: HTTPRequest

Post by thanos »

Peter wrote: Sat Apr 08, 2023 6:05 pm If you look at the output in the Developer Console of your browser, you will see the following:
Access to XMLHttpRequest at 'https://www.adouros.gr/projects/papertr ... 0976679930' from origin 'http://127.0.0.1:9080' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
I.e., for security reasons, access to a resource of another address has been denied.

If you own the web server that runs this php file, then you can allow CORS access. If not, then you only have the diversions via a component that is located on your web server.
Thank you very much for your response!
I will check it.
For the record, I got the save error if I try to access the script from localhost which running xampp server. E.g.
localhost:8080/papertrade/pelates.php
Is it expected?
User avatar
Paul
Posts: 195
Joined: Wed Feb 26, 2014 6:46 pm
Location: Canada
Contact:

Re: HTTPRequest

Post by Paul »

Your SpiderBasic code must be exported and run from the same server as your script.
If you are running your code from the IDE you will have the same problem.
thanos
Posts: 5
Joined: Sat Apr 15, 2017 3:44 pm

Re: HTTPRequest

Post by thanos »

Paul wrote: Tue Apr 11, 2023 9:03 pm Your SpiderBasic code must be exported and run from the same server as your script.
If you are running your code from the IDE you will have the same problem.
Thanks Paul.
I run the code, in both cases, from the IDE
I will try to export it
Regards
plouf
Posts: 194
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: HTTPRequest

Post by plouf »

if your you want to TEST on your computer install a CORS plugins to allow it
-> viewtopic.php?f=6&t=2186&p=8235#p8235

offcourse when finished both script and server must be match for security reasons, but these plugins help development a lot..
Christos
Post Reply