sendYo.lua 857 B

1234567891011121314151617181920212223242526
  1. --This code assumes that the WIFI AP has already been set up
  2. file.open("yorecipient.txt", "r")
  3. print("sending yo to "..file.readline())
  4. file.close()
  5. function generateContentString()
  6. file.open("yorecipient.txt", "r")
  7. return "api_token=99c680b7-5f9f-48fd-9459-46cda7e1c8fa&username="..string.upper(file.readline())
  8. end
  9. sk = nil
  10. sk = net.createConnection(net.TCP,0)
  11. sk:on("receive", function(sck, c) print(c) end )
  12. sk:on("connection", function(sk, payload)
  13. contentString = generateContentString()
  14. strlen = string.len(contentString)
  15. sk:send("POST /yo/ HTTP/1.1\r\n"
  16. .."Host: api.justyo.co\r\n"
  17. .."Connection: close\r\n"
  18. .."Content-Length: "..strlen.."\r\n"
  19. .."Accept: */*\r\n"
  20. .."Content-type: application/x-www-form-urlencoded\r\n\r\n"
  21. ..contentString)
  22. end)
  23. sk:connect(80, "api.justyo.co")