messages/text.py
def send(self):
        """
        Send the SMS/MMS message.
        Set self.sid to return code of message.
        """
        url = (
            "https://api.twilio.com/2010-04-01/Accounts/"
            + self._auth[0]
            + "/Messages.json"
        )
        data = {
            "From": self.from_,
            "To": self.to,
            "Body": self.body,
            "MediaUrl": self.attachments,
        }

        if self.verbose:
            print(
                "Debugging info"
                "\n--------------"
                "\n{} Message created.".format(timestamp())
            )

        try:
            resp = requests.post(url, data=data, auth=(self._auth[0], self._auth[1]))
            resp.raise_for_status()
        except requests.exceptions.RequestException as e:
            exc = "{}\n{}".format(e, resp.json()["message"])
            raise MessageSendError(exc)

        self.sid = resp.json()["sid"]

        if self.verbose:
            print(
                timestamp(),
                type(self).__name__ + " info:",
                self.__str__(indentation="\n * "),
                "\n * HTTP status code:",
                resp.status_code,
            )

        print("Message sent.")

        return resp
def send(self):
        """
        Send the SMS/MMS message.
        Set self.sid to return code of message.
        """
        url = (
            "https://api.twilio.com/2010-04-01/Accounts/"
            + self._auth[0]
            + "/Messages.json"
        )
        data = {
            "From": self.from_,
            "To": self.to,
            "Body": self.body,
            "MediaUrl": self.attachments,
        }

        if self.verbose:
            print(
                "Debugging info"
                "\n--------------"
                "\n{} Message created.".format(timestamp())
            )

        try:
            resp = requests.post(url, data=data, auth=(self._auth[0], self._auth[1]))
            resp.raise_for_status()
        except requests.exceptions.RequestException as e:
            exc = "{}\n{}".format(e, resp.json()["message"])
            raise MessageSendError(exc)

        self.sid = resp.json()["sid"]

        if self.verbose:
            print(
                timestamp(),
                type(self).__name__ + " info:",
                self.__str__(indentation="\n * "),
                "\n * HTTP status code:",
                resp.status_code,
            )

        print("Message sent.")

        return resp
def send ( self ) : url = ( "https://api.twilio.com/2010-04-01/Accounts/" + self . _auth [ 0 ] + "/Messages.json" ) data = { "From" : self . from_ , "To" : self . to , "Body" : self . body , "MediaUrl" : self . attachments , } if self . verbose : print ( "Debugging info" "\n--------------" "\n{} Message created." . format ( timestamp ( ) ) ) try : resp = requests . post ( url , data = data , auth = ( self . _auth [ 0 ] , self . _auth [ 1 ] ) ) resp . raise_for_status ( ) except requests . exceptions . RequestException as e : exc = "{}\n{}" . format ( e , resp . json ( ) [ "message" ] ) raise MessageSendError ( exc ) self . sid = resp . json ( ) [ "sid" ] if self . verbose : print ( timestamp ( ) , type ( self ) . __name__ + " info:" , self . __str__ ( indentation = "\n * " ) , "\n * HTTP status code:" , resp . status_code , ) print ( "Message sent." ) return resp
Send the SMS/MMS message.
        Set self.sid to return code of message.
Send the SMS / MMS message . Set self . sid to return code of message .