get_lastest_dweet() queries the dweet.io service to retrieve the latest dweet (if any) made for our thing. Following is an example of the JSON response we expect to receive. It is the content.state property on line (1) that we are ultimately interested in:
{
this: "succeeded",
by: "getting",
the: "dweets",
with: [
{
thing: "a8e38712-9886-11e9-a545-68a3c4974cd4",
created: "2019-09-16T05:16:59.676Z",
content: {
state: "on" # (1)
}
}
]
}
Looking at the following code, we see, on line (6), the creation of the resource URL used to query the dweet.io service. A call to this URL will return us a JSON similar to that shown in the preceding. You will find a link in the Further reading section to the complete dweet.io API reference.
Next, on line (7), the requests module...