How to get HTTPRequest() working with xampp locally?

Just starting out? Need help? Post your questions and find answers here.
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

How to get HTTPRequest() working with xampp locally?

Post by T4r4ntul4 »

Hi all,

I have on my computer (localhost) a xampp server with a mysql database and php files.
On the same machine i have SpiderBasic with a script with a HTTPRequest() in it.

When i put my local ip in HTTPRequest() and i press F5 for testing it, then it gives a HTTPRequest error.
But if i put my webhost name in HTTPRequest() to my webhost php file. it can succesfully retrieve the contents of the php file.

What is the difference between them? Both are different servers anyway. Locally on the same computer doesnt work, but on my webserver (without changing anything) it works.

I dont need a solution when i need to export it, but i want to have it that it is working with F5 (when developing the software).

Is this possible?

Any help is very appreciated!
plouf
Posts: 194
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: How to get HTTPRequest() working with xampp locally?

Post by plouf »

browsers do not allow you to retrieve data between domains (CORS restrictions)
so do you access you local http server using a diffrent port it is consider as cors violation

i have NOT checked with mysql, but i am almost certain that if you install in local browser a CORS disabler plugin (exist for firefox/chrome etc)

https://addons.mozilla.org/en-US/firefo ... ow-origin/
https://addons.mozilla.org/en-US/firefo ... s-unblock/
(both addons untested by me just suggestions)
Christos
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

Re: How to get HTTPRequest() working with xampp locally?

Post by T4r4ntul4 »

I tried 3 different add-ons, but doesnt work.

Any other ideas?
plouf
Posts: 194
Joined: Tue Feb 25, 2014 6:01 pm
Location: Athens,Greece

Re: How to get HTTPRequest() working with xampp locally?

Post by plouf »

the following example code displays "hello" in debugger (so it does access it and reads) with the first plugin -> https://mybrowseraddon.com/access-contr ... pe=install
(note that after isntalled this plugin you must click "on" on top right icon labeled "C" to become orange=active)

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, "http://192.168.1.10/plouf/hello.php", "", @HttpGetEvent())
php code

Code: Select all

<?php
 echo "hello";
?>

therefore this way it works, if still do not work for you, provide some example code to test it further
Christos
User avatar
T4r4ntul4
Posts: 132
Joined: Wed May 21, 2014 1:57 pm
Location: Netherlands
Contact:

Re: How to get HTTPRequest() working with xampp locally?

Post by T4r4ntul4 »

Hi, thanks for your example, and it works now.

I did something wrong on my part, when i compared your code with mine, i didnt add 'http://' before the ip address, and with the plugin its working now :D

Thank you for your testing.
User avatar
Kurzer
Posts: 90
Joined: Mon May 26, 2014 9:33 am

Re: How to get HTTPRequest() working with xampp locally?

Post by Kurzer »

I had the same problem in my project "database interface module" and got some great help from the user Peter.

If you want to solve the problem without using a browser addon, please have a look in the first post of this thread:
viewtopic.php?p=7403#p7403

The interesting stuff is in section 2) "The following line can be found in the PHP file "config.php" in the config directory..."

Kind regards
Markus
SB 2.32 x86, Browser: Iron Portable V. 88.0.4500.0 (Chromium based), User age in 2023: 55y
"Happiness is a pet." | "Never run a changing system!"
Post Reply