Package: pythontextnow
A Python wrapper for TextNow.TextNow WebsiteTable of ContentsInstallationUsageConfigure ClientGet MessagesSend a MessageSend MediaMark a Message as ReadDelete a MessageDelete a ConversationSetupObtaining Your UsernameObtaining Your CookiesRunning TestsContributingLicenseInstallationUse the package managerpipto install.pipinstallpythontextnowUsageMake sure you have the following before you begin:TextNow usernameSID cookieFor a guide on how to obtain these for your account, checkhere.Configure ClientBefore you can call any methods, you must first set up your client config.frompythontextnowimportClientUSERNAME="{your_username}"SID_COOKIE="{your_sid_cookie}"Client.set_client_config(username=USERNAME,sid_cookie=SID_COOKIE)The ConversationService is how you will perform any action.It takes a list of phone numbers which define the conversation you would like to perform your actions on.All phone numbers must be given inE.164 format.frompythontextnowimportConversationServicePHONE_NUMBER_1="{some_phone_number}"PHONE_NUMBER_2="{some_other_phone_number}"conversation_service=ConversationService(conversation_phone_numbers=[PHONE_NUMBER_1,PHONE_NUMBER_2])Get MessagesTheget_messages()method will return agenerator object.This will return the messages from most -> least recent.You can callnext()with the returned generator each time you want to get the next group of messages.messages_generator=conversation_service.get_messages()messages=next(messages_generator)You can also use a for loop to get all messages in a conversation.messages_generator=conversation_service.get_messages()all_messages=list()formessage_listinmessages_generator:all_messages+=message_listYou can specify how many messages back you would like to be retrieved by using thenum_messageskeyword argument.messages_generator=conversation_service.get_messages(num_messages=10)last_10_messages=list()formessage_listinmessages_generator:last_10_messages+=message_listSend a MessageTo send a text message, use thesend_message()method.conversation_service.send_message(message="Hello World!")Send MediaTo send media, use thesend_media()method.You can send:ImagesVideosGIFsconversation_service.send_message(file_path="C:\\my_media.png")Mark a Message as ReadTo mark a message as read, use themark_as_read()method.Mark a single message as read.# assume you had a Message object saved to the variable "message_obj"conversation_service.mark_as_read(message=message_obj)Mark a list of messages as read.# assume you had a list of Message objects saved to the variable "message_list"conversation_service.mark_as_read(messages=message_list)Delete a MessageTo delete a message, use thedelete_message()method.Delete a message by its ID.conversation_service.delete_message(message_id="123456")Delete a message with itsMessageobject.# assume you had a Message object saved to the variable "message_obj"conversation_service.delete_message(message=message_obj)Delete a ConversationTo delete a conversation, use thedelete_conversation()method.conversation_service.delete_conversation()SetupObtaining Your UsernameYou will need to know your TextNow username to utilize this library.This is the same username that you would use to log in.To find this username:Go toTextNow's messaging page(make sure you are logged in)Click "Settings"Your username will be listed under "Account"Obtaining Your CookieYou will need an SID cookie to utilize this library.To find this cookie:Go toTextNow's messaging page(make sure you are logged in to your account)InChrome:AccessDeveloper Toolsin your browserClick on the "Application" tabClick on the "Network" tabFind a request under "Fetch/XHR"Go to the "Headers" tab in the given requestFind the "Request Headers" sectionLocate the "Cookie" fieldInFirefoxAccessDeveloper Toolsin your browserClick on the "Network" tabFind a request under "XHR"Go to the "Headers" tab in the given requestFind the "Request Headers" sectionLocate the "Cookie" fieldLocate the "connect.sid" field, the value will be your SID cookieRunning TestsTo run tests, run the following command:pytestContributingPull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.Please make sure to update tests as appropriate.LicenseMIT