cannot use http_post_string to localhost

A

AliBahrami

Guest
I have a domain name and the code works perfectly on it. When I try to use localhost instead of the url, I cannot.
So the problem must lie in the wamp, which I use, and the comminucation and ports.
code in game maker studio :

input_team = get_string("Enter your team name", "")
input_pass = get_string("Enter your pass", "")
send = "name=" + string(input_team) + "pass=" + string(input_pass)
post = http_post_string("http://www.bahramiehsan.com/check_inputs.php?", send)

code in php:
<?php
$obj->tacticT = 3;
$obj->bodyT = 4;
$obj->goalT = 1;
$j = json_encode($obj);
echo $j;
return $j;


when I remove the url and add localhost, even I copy and paste it in browser and it works, game maker cannot do the right thing.
Thanks for any help
 
J

jmack20093

Guest
i know this is old, but for future people who find this just add "http://" in front of localhost. It seems like game maker requires it.
 

PNelly

Member
i know this is old, but for future people who find this just add "http://" in front of localhost. It seems like game maker requires it.
This is also often necessary in the "real world", if you're trying to hit a particular IP without it's domain name.
 
G

Guest User

Guest
So is any other software. You need a virtual host for this operation to work i.e a domain, I am not sure if this is going to work for GameMaker but it worked for me when I was using PayPal APIs to send to Localhost, as a matter of fact, you don't really need a domain, or at least you don't need to buy a domain.

To get this to work you need to build a server in your computer. How you may ask?
Download and install Xampp and get the server running.
You need to list your domain name in the hosts file in your windows folder, follow this path and you will find it
Code:
C:\Windows\System32\drivers\etc
add your domain name at the very bottom of the hosts
Code:
127.0.0.1   yourwebsite.com
127.0.0.1   www.yourwebsite.com
Then from Xampp control panel edit the Apache httpd.conf files and configure a virtual host for your domain.

This is just a brief idea, with simple Google search you can find many articles that show you how to achieve this. Here is an article I've just found https://blog.tormix.com/development/xampp-change-localhost-to-custom-domain-name/

Tell if it works for you :)
 
Top