im trying to use “send a request to a web page” action
but it nothing happens when I try it.
here is a screenshot of the settings
am i doing something wrong ?
im trying to use “send a request to a web page” action
but it nothing happens when I try it.
here is a screenshot of the settings
am i doing something wrong ?
Are you sure about that content type field?
Look here maybe helps
i have managed to connect to the website i get the page html in responce.
but im trying to send 2 variables from gdevelop with POST and its not working
any idea why?
here is what i have in request body content
“{“score”: " + VariableString(Score) + " } {“name”: " + VariableString(name) + " }”
can this be a server issue ?
Look this is how I do a post request to my PHP API, since I use “application/x-www-form-urlencode”
The request url has to be separated with “&”
like ¶m1=1¶m2=bla¶m3=120
i tryed but no luck the php website does not get the post variables…
maby this is a server issue
Tell me which url and which data I need to post and I’ll test later.
the server does not allow crossdomain request i think
here is the url
http://einar.fast-page.org/hs.php
I need to post the variables name and score
im using
$name = $_POST[‘name’];
$score = $_POST[‘score’];
to get the varibles
Post to that url returns an HTML output but not a JSON response or $_POST response,
Anyway check your .htaccess into the public_html or www or your root folder in your server
Add to .htaccess
Header add Access-Control-Allow-Origin "*"
Header add Access-Control-Allow-Methods: "GET,POST,OPTIONS,DELETE,PUT"
In your php when you proccess the POST request
Add
// Allow from any origin
if (isset($_SERVER[‘HTTP_ORIGIN’])) {
// should do a check here to match $_SERVER[‘HTTP_ORIGIN’] to a
// whitelist of safe domains
header(“Access-Control-Allow-Origin: {$_SERVER[‘HTTP_ORIGIN’]}”);
header(‘Access-Control-Allow-Credentials: true’);
header(‘Access-Control-Max-Age: 86400’); // cache for 1 day
}
// Access-Control headers are received during OPTIONS requests
if ($_SERVER[‘REQUEST_METHOD’] == ‘OPTIONS’) {
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD']))
header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']))
header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
}
Oh and you need to do this for the post format in GDevelop
“&name=” + VariableString(name) + “&score=” + VariableString(score)
Note the & before name and & before score in both of the parameters.
thanks for trying to help… I could not get it to work…
only thing i get is the html of the page in responce
In that case if you want help you will have to post your backend code
I Got it to work there was a typo. thanks for all help