def query_api(self, data=None, endpoint='SMS'):
        url = self.api_url % endpoint
        if data:
            conn = Request(url, b(urlencode(data)))
        else:
            conn = Request(url)

        auth = b('Basic ') + b64encode(b(self.username + ':' + self.password))
        conn.add_header('Authorization', auth)

        try:
            response = urlopen(conn)
        except __HOLE__ as err:
            print(err)
            print("\nSending didn't succeed :(")
            exit(-2)
        return response.read()
dataset/ETHPy150Open 46elks/elkme/elkme/elks.py/Elks.query_api