🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Using a API to send out a SMS

    M5 Stick/StickC
    2
    3
    4.3k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      rbrakus
      last edited by rbrakus

      After running this code, I get no errors only a blank screen. Could anyone tell what I did wrong at first glance?

      from m5stack import *
      from m5ui import *
      from uiflow import *

      fields = {
      'from': 'PythonElk',
      'to': '+XXXXXXXX',
      'message': 'Test Message To your phone.'
      }
      try:
      req = urequests(
      method='POST',
      url='https://api.46elks.com/a1/SMS',
      headers=fields,
      data={'XXXXXXXXXXXXXXXXXXXXX',' YYYYYYYYYYYYYYYYYYYY'}
      )
      except Exception as e:
      print(e)
      import urequests
      import ujson
      setScreenColor(0x111111)
      auth = (
      'XXXXXXXXXXXXXXXXXXXXXXXX',
      'YYYYYYYYYYYYYYYYYYYYYY'
      )
      fields = {
      'from': 'PythonElk',
      'to': '+XXXXXXXX',
      'message': 'Test Message To your phone.'
      }
      headers = {'Content-Type': 'application/json'}
      try:
      #urequests.request(method='POST', url='https://api.46elks.com/a1/SMS', auth, fields,headers
      post_data = ujson.dumps('XXXXXXXXXXXXXXXXXXXXXXX','YYYYYYYYYYYYYYYYYYYYYYYYYYY')
      request_url = 'https://api.46elks.com/a1/SMS'
      res = requests.post(request_url, headers = {'content-type': 'application/json'}, data = post_data,json=fields)
      print(res)

      req = urequests.request(method='POST', url="import urequests setScreenColor(0x222222) fields = { 'from': 'PythonElk', 'to': '+XXXXXXX', 'message': 'Test Message To your phone.' } try: req = urequests.request( method='POST', url='https://api.46elks.com/a1/SMS', headers=fields, data=('XXXXXXXXXXXXXXXX','YYYYYYYYYYYYYYYYYYYYY') ) except: print(req.status_code)",json={'user':'a'}, headers={})

      except Exception as e:
      print(e)

      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by

        I do not see any GUI objects required to show text on the screen. I only see code that runs in the background.

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • R
          rbrakus
          last edited by rbrakus

          Me and a friend of mine figured out how to do a HTTP post with parameters in micropython. Me used it for sending SMS, but it can be modified to anything else.
          https://forum.m5stack.com/topic/1902/http-post-from-arduino-esp8266-esp32-how-to-send-parameters-x-www-form-urlencoded-using-micropython/3

          1 Reply Last reply Reply Quote 0
          • First post
            Last post