These two python scripts will accept a mail message at STDIN and call or text via the Twillio service.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

32 linhas
815B

  1. #!/usr/bin/python3
  2. from twilio.rest import Client
  3. import sys
  4. import email
  5. # Find these values at https://twilio.com/user/account
  6. account_sid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  7. auth_token = "YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY"
  8. client = Client(account_sid, auth_token)
  9. raw_msg = ""
  10. for line in sys.stdin:
  11. raw_msg = raw_msg + line
  12. msg = email.message_from_string(raw_msg)
  13. text = msg['Subject'] + "\n\n"
  14. if msg.is_multipart():
  15. for payload in msg.get_payload():
  16. text = text + payload.get_payload()
  17. else:
  18. text = text + msg.get_payload()
  19. text = text[:160] if len(text) > 160 else text
  20. #print(text)
  21. message = client.api.account.messages.create(to = "+357XXXXXXXX",
  22. from_ = " +177XXXXXXXX",
  23. body = text)