sendYo.lua 655 B

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