This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
DecrepitDoors's profile picture

Trying to make a program, may be in over my head.

Started by DecrepitDoors, 23 February 2015 - 08:38 PM
DecrepitDoors #1
Posted 23 February 2015 - 09:38 PM
Okay so first I'm gonna explain exactly what I want the program then say what I know so far.

The program I would like is one that will get the virtual server statistics from my creeperhost control panel and post them to a monitor in my base.
I've been told by Creeperhost that it should be possible using their API https://cp.creeperhost.net/Aries/ and "http.get" I've managed to get the monitor to display the source code of the site but getting the exact information I want is proving pretty difficult.

If anyone could help it would be really appreciated.
Lyqyd #2
Posted 23 February 2015 - 10:13 PM
Moved to Ask a Pro.
deeredman1991 #3
Posted 23 February 2015 - 11:25 PM
Could you use creeperhost to write a lua program with the information you need and http.get that in?
Lemmmy #4
Posted 24 February 2015 - 12:08 AM
Now you haven't actually posted the details of what you've done so far, so I can only base this off of assumptions.
If it's displayingsource code for their site, I think you've not used their API correctly. You're probably pointing to an API documentation page or something.

I just looked at the link, and I'm fairly certain you're using https://cp.creeperhost.net/Aries in your http.get method. This is wrong because that page is an example page.
This page says that you need to post the data, not get it. You may want to familiarise yourself with both their API and the differences between the HTTP GET and POST methods. When you're ready for that, look at http.post

An example could be:

local apiLocation = "https://api.creeperhost.net/os/getram"
--# api.creeperhost.net is the api
--# os is the service
--# getram is the command
local key = "YOURKEY"
local secret = "YOURSECRET"
local response = http.post(
  apiLocation, --# where the api is
  "key="..textutils.urlEncode(key).."&".. --# your key (i dont know what this is, you should)
  "secret="..textutils.urlEncode(secret) --# your secret (i dont know what this is, you should)
)
--# do your stuff
response.close();

Note: This example is made up on the spot - you may have to adjust it or it may not even work but it should help you get started.
Edited on 24 February 2015 - 02:42 PM
DecrepitDoors #5
Posted 01 March 2015 - 01:48 AM
Now you haven't actually posted the details of what you've done so far, so I can only base this off of assumptions.
If it's displayingsource code for their site, I think you've not used their API correctly. You're probably pointing to an API documentation page or something.

I just looked at the link, and I'm fairly certain you're using https://cp.creeperhost.net/Aries in your http.get method. This is wrong because that page is an example page.
This page says that you need to post the data, not get it. You may want to familiarise yourself with both their API and the differences between the HTTP GET and POST methods. When you're ready for that, look at http.post

An example could be:

local apiLocation = "https://api.creeperhost.net/os/getram"
--# api.creeperhost.net is the api
--# os is the service
--# getram is the command
local key = "YOURKEY"
local secret = "YOURSECRET"
local response = http.post(
  apiLocation, --# where the api is
  "key="..textutils.urlEncode(key).."&".. --# your key (i dont know what this is, you should)
  "secret="..textutils.urlEncode(secret) --# your secret (i dont know what this is, you should)
)
--# do your stuff
response.close();

Note: This example is made up on the spot - you may have to adjust it or it may not even work but it should help you get started.

Tried this with the right details but its returning with bios: 366: [string "test"]: 8: '<name>' ecprected
Been working on this for a while, got some help from reddit but it never ended up working properly.