Sending info to a real website
#1
Posted 10 November 2012 - 05:36 AM
#2
Posted 10 November 2012 - 06:39 AM
#3
Posted 10 November 2012 - 06:58 AM
sending data from CC:
local param = 42
http.post('http://example.com/script.php','param='..param)
receiving data in 'script.php' on 'example.com':
$param = $_POST['param'];
#4
Posted 10 November 2012 - 07:25 AM
That means you can feed some GET or POST data to your PHP server, let it do its thing server-side with it and then get the results back.
And I don't know if sIdEkIcK_ meant me, but I have released a working alpha version of a MySQL database connector to the peripheral section.
At the moment I'm working on implementing some updates and ideas that were suggested, as well as making it support not just MySQL but any arbitrary database managment system, as long as there exists a JDBC driver for it.
If you want to give the alpha a try, look at my sig for the link. I'd be glad to have people test it for bugs and give ideas.
Cheers
EDIT: The only thing that's not implemented yet is manipulating data though. I first wanted to see if everything worked and figured most of the time people would want to request data.
#5
Posted 10 November 2012 - 07:40 AM
So that if you do
http://www.somerandomsite.com/?this=is&a=way&to=send&info=to&a=site(And yeah I know I declared "a" twice)
#6
Posted 10 November 2012 - 08:33 AM
#7
Posted 10 November 2012 - 09:10 AM
local content = http.get('http://example.com/script.php','param='..42)
local answer = content.readAll()
and in 'script.php':
$param = $_GET['param']; echo 'answer variable';
#8
Posted 10 November 2012 - 09:25 AM
Espen, on 10 November 2012 - 07:25 AM, said:
That means you can feed some GET or POST data to your PHP server, let it do its thing server-side with it and then get the results back.
And I don't know if sIdEkIcK_ meant me, but I have released a working alpha version of a MySQL database connector to the peripheral section.
At the moment I'm working on implementing some updates and ideas that were suggested, as well as making it support not just MySQL but any arbitrary database managment system, as long as there exists a JDBC driver for it.
If you want to give the alpha a try, look at my sig for the link. I'd be glad to have people test it for bugs and give ideas.
Cheers
EDIT: The only thing that's not implemented yet is manipulating data though. I first wanted to see if everything worked and figured most of the time people would want to request data.
Yes, I meant you
#9
Posted 10 November 2012 - 10:22 AM
Orwell, on 10 November 2012 - 09:10 AM, said:
local content = http.get('http://example.com/script.php','param='..42)
local answer = content.readAll()
and in 'script.php':
$param = $_GET['param']; echo 'answer variable';
Also is there any MD5 hashing or any other type of hashing in Lua?.
#10
Posted 10 November 2012 - 10:43 AM
Jasonfran, on 10 November 2012 - 10:22 AM, said:
But most of them aren't pure Lua implementations and rely on other libraries, etc.
I found one post on StackOverflow where someone posted a pure Lua implementation of MD5 (last post):
http://stackoverflow...entation-of-md5
He basically combined another, library-dependent version together with the very libraries it depends upon.
I haven't tested it, but I guess it will be rather slow.
But someone could make a peripheral that exposes a collection of all kinds of useful hashing functions.
That way you'd have the speed of Java, at the cost of having to install a peripheral.
#11
Posted 10 November 2012 - 10:58 AM
Espen, on 10 November 2012 - 10:43 AM, said:
Jasonfran, on 10 November 2012 - 10:22 AM, said:
But most of them aren't pure Lua implementations and rely on other libraries, etc.
I found one post on StackOverflow where someone posted a pure Lua implementation of MD5 (last post):
http://stackoverflow...entation-of-md5
He basically combined another, library-dependent version together with the very libraries it depends upon.
I haven't tested it, but I guess it will be rather slow.
But someone could make a peripheral that exposes a collection of all kinds of useful hashing functions.
That way you'd have the speed of Java, at the cost of having to install a peripheral.
#12
Posted 10 November 2012 - 11:07 AM
Jasonfran, on 10 November 2012 - 10:58 AM, said:
Espen, on 10 November 2012 - 10:43 AM, said:
Jasonfran, on 10 November 2012 - 10:22 AM, said:
But most of them aren't pure Lua implementations and rely on other libraries, etc.
I found one post on StackOverflow where someone posted a pure Lua implementation of MD5 (last post):
http://stackoverflow...entation-of-md5
He basically combined another, library-dependent version together with the very libraries it depends upon.
I haven't tested it, but I guess it will be rather slow.
But someone could make a peripheral that exposes a collection of all kinds of useful hashing functions.
That way you'd have the speed of Java, at the cost of having to install a peripheral.
#13
Posted 10 November 2012 - 12:19 PM
Human, on 10 November 2012 - 11:07 AM, said:
Jasonfran, on 10 November 2012 - 10:58 AM, said:
Espen, on 10 November 2012 - 10:43 AM, said:
Jasonfran, on 10 November 2012 - 10:22 AM, said:
But most of them aren't pure Lua implementations and rely on other libraries, etc.
I found one post on StackOverflow where someone posted a pure Lua implementation of MD5 (last post):
http://stackoverflow...entation-of-md5
He basically combined another, library-dependent version together with the very libraries it depends upon.
I haven't tested it, but I guess it will be rather slow.
But someone could make a peripheral that exposes a collection of all kinds of useful hashing functions.
That way you'd have the speed of Java, at the cost of having to install a peripheral.
#15
#16
Posted 11 November 2012 - 06:03 AM
I can send this easily
http.request("http://website.com/Read1.php", "username=" .. username)
But i want to send username and message in one request like this:
http.request("http://website.com/Read1.php", "username=" .. username, "message=" .. message)
is it possible? Because i cant seem to get it to work. If this dont work then I suppose I'd have to use http.get
Edit: Dont matter. Found out I had to put an & inbetween
#17
Posted 11 November 2012 - 06:42 AM
http.request( "http://website.com/Read1.php?username="..username.."&message="..message )
Generally, you can add the first parameter to a url with ? and every consecutive one with &
Edit:
Dammit, it WAS Lua. Ok un-fixed. Thought you were talking about PHP. ^^
Edited by Espen, 11 November 2012 - 06:45 AM.
#18
Posted 11 November 2012 - 08:28 AM
Espen, on 11 November 2012 - 06:42 AM, said:
http.request( "http://website.com/Read1.php?username="..username.."&message="..message )
Generally, you can add the first parameter to a url with ? and every consecutive one with &
Edit:
Dammit, it WAS Lua. Ok un-fixed. Thought you were talking about PHP. ^^
#19
Posted 05 January 2013 - 10:29 PM
What I have now is basically Cloud Storage for CC computers, that can be read/written by anything that can send a HTTP GET request. So, you can turn off your nuclear plant from a smartphone, or overload it using a Big Red Button (by polling things).
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











