FailedRequest server error 520 when sending message using PyTextNow - python

Over the summer, I was successfully using the PyTextNow python library to send text messages from my raspberry pi to my phone with python. I stopped using it for a while, around a month. When I tried to use it again, my phone number on TextNow had expired and I was given new one. Since then, I have been unable to use my previous code even though I made all the needed adjustments for the new phone number. I get error that looks like this: FailedRequest: Could not send message. server return a Server error. Request Failed. Status Code: 520
Here is my code
import pytextnow as pytn
client = pytn.Client(#username#, #connect.sid#)
client.send_sms("phone #", "Hello")
I have verified that the username, connect.sid cookie, and phone number are all correct numerous times. I also set up a second TextNow account, modifying the code with the new username and connect.sid values, and got the same error. I know that I am connecting to the correct account because the client.get_unread_messages() function will pull up the correct messages. To my knowledge, it is only the send message function that is not working. Any help that would enable me to send sms messages again with PyTextNow, or a better way to send and read messages in python, would be appreciated. Thanks!

Related

Intepreting text messages using Python

Is it possible to create a python script that allows you to intepret messages received on your phone?
For example, when you receive an OTP on your phone, the computer can process it and use the code to log in to a website. For Macbooks, its possible to connect your iphone's messages to your Macbook, such that when a message is received on the iphone, it will also be forwarded to your mac. Thus, I plan to use this function as part of my python automation process that can utilise the OTP received on my devices to log in to a specfic website without having to manually key it in everytime it is being requested.
I tried searching online but there doesn't seem to have a solution to this

Send whatsapp massage from Twilio using my number

I want to send an invitation for an event using Twilio API using my own number.
It will be very good if the "log" of the messages will be also saved in my phone.
Is it possible to do it with the API?
Sadly it seemed to be possible only after updating, so I've updated and paid the money and now I see that it's not that easy. The API is very confusing.
How can I do it?
When I write my number at the "From" I get:
twilio.base.exceptions.TwilioRestException: HTTP 400 error: Unable to create record: Twilio could not find a Channel with the specified From address
Is it possible to do it?
Thanks
If you are talking about sending a message from your own phone number (your cell phone), this can not be done with Twilio.
From the Twilio docs:
Note: You can not spoof messages from your own cell phone number. TheĀ FromĀ parameter can only display a Twilio number on your project, or an Alphanumeric Sender ID (where available).

Adding Password to Logon message with QuickFix

Hi there I am having issues with Quick Fix python. I need to add Tag 554 to my outbound Logon message to send messages in to the exchange as it is required but I am unsure how to go about this. All the online examples I find are C++ code and my attempts to translate those to Python are not successful.
If someone could advise how to send Logon messages out with a password tag it would be appreciated:
def toAdmin(self, sessionID, message):
message.getHeader().setField(554, "password")
Your code looks close to correct. You didn't actually say what happens you run it, so I can't be 100% sure what you think is wrong with it.
But there is one improvement that is needed: You only want to set the password on Logon messages.
def toAdmin(self, sessionID, message):
if message.getHeader().getField(35) == "A":
message.getHeader().setField(554, "password")
(Forgive any Python syntax errors; it's not a language I know well.)
This is very similar to what you'd do in any other QF port. For instance, see the QuickFIX/n User FAQ for the C# way.

QuickFIX logon trouble: multiple rapid fire logon attempts being sent

QuickFIX logon trouble: (using QuickFIX, with FIX 4.4 in Python 2.7)
Once I do initiator.start() a connection is made, and logon message is sent. However, I don't ever see the ACK and session status message that the broker is sending back (all the overloaded Application methods are just supposed to print out what they receive).
QuickFIX immediately re-tries the logon (according to the broker log files), and the same thing happens, but according to the server, I am already logged in.
QuickFIX then issues a Logout command, which the server complies with.
I have tried enter Timeout values in the settings file, but to no avail. (Do I need to explicitly reference these values in the code to have the utilized, or will the engine see them and act accordingly automatically?)
Any ideas what is going on here?
Sounds like you do not have message logs enabled. If your app rejects messages below the application level (such as if the seq no is wrong, or the message is malformed), then it'll be rejected before your custom message handlers even see it.
If you are starting your Initiator with a ScreenLogStore, change it to a FileLogStore. This will create a log file that will contain every message sent and received on the session, valid or not. Dollars to donuts you'll see your Logon acks in there as well as some Transport-layer rejections.
Solved! I think there was something wrong with my datadictionary (FIX44.xml) file. I had seen a problem in it before, but thought I fixed it. I got a new copy online and dropped it in and now everything seems to be working. Maybe the bad dictionary was not letting FIX accept the logon response?

Handling / Bouncing Incoming Email on Errors with App Engine Python

When an email is received that generates an error what is the best way to bounce the message? For example you store a file in a db.BlobProperty but an email comes in that exceeds the 1m limit. There needs to be a bounce error to the request somehow so the email doesn't keep hitting the server and increasing the billing every 15 minutes. (Don't ask me how I know :-P ... not really it is a separate but related issue I posted in another question. here )
But that other error made it clear I need to deal with this before I get that email with multiple attachments that nails me for 1gb of data.
Normally the mail server handles the bounce, like when you send to a bad address and returns an error to the client/server. I have searched and didn't find anything helpful on this. YMMV
Is there an undocumented function? What is the proper response to return so that the originating server stops sending?
There's no way to bounce a message once it arrives at your App Engine app. You have two options:
Send the user a 'bounce message' yourself using the outgoing email API
Silently discard the message
In either case, you should install a top-level exception handler (frameworks like webapp and webapp2 have support for this) that logs the exception, performs the appropriate action, and then returns status code 200 instead of 500, so the message won't be redelivered repeatedly.
In your specific case, too, I'd start storing the attachments in the blobstore instead of a blob property, to avoid the 1MB limit.

Categories