Hi, recently I’ve seen some new people join, and some people quit because they got frustrated. So I decided to make this thread. The rules are simple, know what you are talking about, and make if its a hard to learn subject, add the requirements.
Here is mine:
Requirements: Basic Lua Pattern knowledge (Highly suggested)
Hello everybody, today we will be learning about the http.request. In a nutshell, you can access a websites source code, and pick out the parts you want to display. There are other things you can do with it, like sending data to it. But since I don’t have a website to test it out on, we won’t be covering that.
The first thing you will need to know is how to link a url to it. Most of you now a days don’t use http://www.websiteName.com anymore, since google and other search engines have made it easier. But Codea still needs it. so inside of the http.request type this:
Thats not all we need to add though. If thats it, then where would it put all the informtion? For this we have to make two functions for it, the fail function if it can’t reach the website, and the success function if it did reach it. You can name them whatever you like.
You should now have this:
http.request("http://www.example.com", success, fail)
Now we add the functions.
function fail(error) end
function success(data,status,header) end
We added the callbacks inside of the functions that way the http.request knows where to send things. In this tutorial we will just be covering the data and error one, though.
If you add a
Inside of the success function now, you will see quite a few lines of code. Don’t let this scare you off, though. A lot of it Codea Doesn’t need!
While most of you have seen the reference inside of Codea explaining this, it isn’t always that easy. Most of the time you will have to find the information you need. So if I went to http://www.merriam-webster.com/dictionary/dog and tried catching information about it, like the orgin. I would have to manually find the part of the code that talks about it, and sub.string() and string.match() until I just get that part of the information.