749 posts
Location
BOO!!
Posted 29 April 2016 - 02:04 PM
I have lua:
response = http.post('https://ccraft-jasongronn.c9users.io/test.php')
print(reponse.readAll())
And I have PHP:
[php]<!doctype PHP>
<php>
<?php
date_default_timezone_set("America/New_York");
$hour = date('h')%13;
$luaTime = date($hour.':i a');
echo $luaTime;
?>
</php>[/php]
It keeps giving me the PHP code as a response. Can I send a custom reponse?
1080 posts
Location
In the Matrix
Posted 29 April 2016 - 02:46 PM
Shouldn't you technically use http.get?
749 posts
Location
BOO!!
Posted 29 April 2016 - 02:59 PM
Shouldn't you technically use http.get?
Well, that makes it harder to use URL php variables.
Also, I think http.get would make it worse, because that's even more likely to send the code, tags and all, and that's just what I don't want to do.
Edited on 29 April 2016 - 01:00 PM
7083 posts
Location
Tasmania (AU)
Posted 29 April 2016 - 03:06 PM
It'll "work" either way, so long as your PHP server is doing its job.
749 posts
Location
BOO!!
Posted 29 April 2016 - 03:14 PM
It'll "work" either way, so long as your PHP server is doing its job.
And what should I do to send a real response rather than HTML (or PHP, or hypertext preprocessor, or whatever)
7083 posts
Location
Tasmania (AU)
Posted 29 April 2016 - 03:19 PM
Leave the PHP server running, I guess? Putting aside your typo in "response", it works as-is.
749 posts
Location
BOO!!
Posted 29 April 2016 - 03:27 PM
I originally named 'response' 'request'. That was an editing error.
Leave the PHP server running, I guess?
At the time, it's running. That is, however, one of my concerns.
749 posts
Location
BOO!!
Posted 29 April 2016 - 07:23 PM
What I mean is
I want this:
(No HTML)(No whitespace)(PHP response)
Rather than:
(HTML)(whitespace)(PHP content)
This is probably a problem with my PHP code not using a response, but I don't know how to send a response
Edited on 29 April 2016 - 05:24 PM
1243 posts
Location
Indiana, United States
Posted 29 April 2016 - 07:26 PM
Instead of
<!doctype PHP>
<php>
<?php
date_default_timezone_set("America/New_York");
$hour = date('h')%13;
$luaTime = date($hour.':i a');
echo $luaTime;
?>
</php>
You'd want
<?php
date_default_timezone_set("America/New_York");
$hour = date('h')%13;
$luaTime = date($hour.':i a');
echo $luaTime;
?>
That shouldn't produce any whitespace, and definitely no HTML. Of course this is assuming your server is configured correctly to serve PHP.
749 posts
Location
BOO!!
Posted 29 April 2016 - 07:40 PM
Instead of
<!doctype PHP>
<php>
<?php
date_default_timezone_set("America/New_York");
$hour = date('h')%13;
$luaTime = date($hour.':i a');
echo $luaTime;
?>
</php>
You'd want
<?php
date_default_timezone_set("America/New_York");
$hour = date('h')%13;
$luaTime = date($hour.':i a');
echo $luaTime;
?>
That shouldn't produce any whitespace, and definitely no HTML. Of course this is assuming your server is configured correctly to serve PHP.
But what if it's to a PHP page that can also be accessed via a user? 'Im planning on upgrading on this and adding a browser interference
1243 posts
Location
Indiana, United States
Posted 29 April 2016 - 07:44 PM
Then have an if statement and a special GET or POST parameter for CC clients to use.
477 posts
Location
Germany
Posted 29 April 2016 - 07:44 PM
Instead of
<!doctype PHP>
<php>
<?php
date_default_timezone_set("America/New_York");
$hour = date('h')%13;
$luaTime = date($hour.':i a');
echo $luaTime;
?>
</php>
You'd want
<?php
date_default_timezone_set("America/New_York");
$hour = date('h')%13;
$luaTime = date($hour.':i a');
echo $luaTime;
?>
That shouldn't produce any whitespace, and definitely no HTML. Of course this is assuming your server is configured correctly to serve PHP.
But what if it's to a PHP page that can also be accessed via a user? 'Im planning on upgrading on this and adding a browser interference
You could probably check the user agent and give a custom one in CC.
Edit: Or do above, but if you put something new to the end of the URL you could just use two scripts. So you should go with POST.
Edited on 29 April 2016 - 05:45 PM
7083 posts
Location
Tasmania (AU)
Posted 30 April 2016 - 12:57 AM
What I mean is
I want this:
(No HTML)(No whitespace)(PHP response)
And that was and still is exactly what you get.