Great week everyone! We only have five classes left!
First of all, if anyone needs to send a program via email, this is sometimes more difficult than it should be. Email programs tend to be wary of people attaching programs to emails. Therefore, to send one, you need to (a) rename the file so it doesn’t end in .js or .html. Just rename the file to .txt. Then (b) compress the file into a zip file (this can usually be done by right-clicking on the file).
Now to this week. For those who missed it, this week we practiced using the programmable web – using URLs to fetch JSON files, parse them, and use their data in our own programs. Below are the two files we typed in:
What this code does is go to the EventElf website, get a JSON feed of an event, and pull down some of the information into a web page. The things we used are:
- XMLHttpRequest – this object allows us to make connections to other websites for data. We have to use new to get a new copy of this object. The onload property should be set to a callback that will trigger when the data is finished loading, and then the actual data itself will be in the responseText property. The open function tells the method (usually “GET” sometimes “POST”) and the URL to obtain. Then, the send function actually makes the call.
From there, we just use document.getElementById like we normally do.
There are a huge number of things on the web accessible by JSON feeds in this way. When you find one, you read the documentation, and it will tell you how to construct URLs to access their data, and what the data looks like. This is known as the API. Unfortuantely, a lot of APIs require you to perform tasks to authenticate yourself and your program, which adds a lot of complexity to the task, especially for new programmers.
We did not talk much about our web store system, but will get more into that next week.
HOMEWORK FOR THIS WEEK:
- Work on your cart program
- Alternatively, you can find another API to interface with. I have been trouble finding an API that is all of (a) easy to use, (b) works with your browser’s security, and (c) does not have any inappropriate content. That is proving difficult 🙂 I will update this if I find one. I found several joke APIs, but they often have both regular and inappropriate jokes. I found a “cat facts” API, but it doesn’t work with your browser’s security. Anyway, if you find one you want to use, feel free to do so!
This week we went into further depth on inductors. If you have not read chapter 22, you should do so. The “apply” section at the end is this week’s homework. I should have the next chapter out this weekend, but the homework will be for chapter 22, which is already there. UPDATE – chapter has been updated on the site.
This week we covered trig substitutions in more depth. I am still working on plans for this week’s homework and next week’s lesson. More information hopefully over the weekend.