add intents docs and samples
This commit is contained in:
26
samples/shttp-text.lua
Normal file
26
samples/shttp-text.lua
Normal file
@@ -0,0 +1,26 @@
|
||||
-- name = "Chuck Norris jokes (experimental)"
|
||||
-- description = "icndb.com"
|
||||
-- data_source = "icndb.com"
|
||||
-- type = "widget"
|
||||
-- author = "Evgeny Zobnin (zobnin@gmail.com)"
|
||||
-- version = "1.0"
|
||||
|
||||
function on_alarm()
|
||||
local response = shttp:get("http://api.icndb.com/jokes/random")
|
||||
|
||||
if response.error ~= nil then
|
||||
ui:show_text(response.error)
|
||||
return
|
||||
end
|
||||
|
||||
if response.code >= 200 and response.code < 300 then
|
||||
joke = ajson:get_value(response.body, "object object:value string:joke")
|
||||
ui:show_text(joke)
|
||||
end
|
||||
end
|
||||
|
||||
function on_click()
|
||||
if joke ~= nil then
|
||||
system:copy_to_clipboard(joke)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user