sendYo.lua 658 B

12345678910111213141516171819202122
  1. wifi.sleeptype(wifi.NONE_SLEEP)
  2. if YO_RECIPIENT ~= nil and YO_RECIPIENT ~= '' then
  3. debugMsg('sending yo to ' .. YO_RECIPIENT)
  4. local contentString = "api_token=" .. API_KEY .. "&username="..string.upper(YO_RECIPIENT)
  5. local contentLength = string.len(contentString)
  6. http.post(
  7. 'https://api.justyo.co/yo/',
  8. 'Content-Type: application/x-www-form-urlencoded\r\n'..
  9. 'Content-length: ' .. contentLength .. '\r\n',
  10. contentString,
  11. function(code, data)
  12. debugMsg("POST REQUEST CALLBACK")
  13. debugMsg("code: " .. code)
  14. debugMsg("data: " .. data)
  15. wifi.sleeptype(wifi.LIGHT_SLEEP)
  16. end
  17. )
  18. else
  19. debugMsg("Yo not sent - invalid YO_RECIPIENT")
  20. end