Coder Social home page Coder Social logo

pytextnow_api's People

Contributors

bryanperez43 avatar leogomezz4t avatar silverstrings024 avatar wunter8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pytextnow_api's Issues

Trouble logging in

I'm trying the first step with logging in but having issues with my csrf cookie not getting used correctly?

Traceback (most recent call last): File "/Users/v/Python/instagram_post/main/texts.py", line 12, in <module> client = pytextnow.Client(username) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/v/Python/instagram_post/.venv/lib/python3.11/site-packages/pytextnow/TNAPI.py", line 79, in __init__ 'x-csrf-token': self.get_initial_csrf_token() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/v/Python/instagram_post/.venv/lib/python3.11/site-packages/pytextnow/TNAPI.py", line 100, in get_initial_csrf_token req = requests.get('https://www.textnow.com/messaging', cookies=self.cookies) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/v/Python/instagram_post/.venv/lib/python3.11/site-packages/requests/api.py", line 76, in get return request('get', url, params=params, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/v/Python/instagram_post/.venv/lib/python3.11/site-packages/requests/api.py", line 61, in request return session.request(method=method, url=url, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/v/Python/instagram_post/.venv/lib/python3.11/site-packages/requests/sessions.py", line 528, in request prep = self.prepare_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/v/Python/instagram_post/.venv/lib/python3.11/site-packages/requests/sessions.py", line 456, in prepare_request p.prepare( File "/Users/v/Python/instagram_post/.venv/lib/python3.11/site-packages/requests/models.py", line 318, in prepare self.prepare_cookies(cookies) File "/Users/v/Python/instagram_post/.venv/lib/python3.11/site-packages/requests/models.py", line 575, in prepare_cookies cookie_header = get_cookie_header(self._cookies, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/Users/v/Python/instagram_post/.venv/lib/python3.11/site-packages/requests/cookies.py", line 142, in get_cookie_header jar.add_cookie_header(r) File "/opt/homebrew/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/cookiejar.py", line 1370, in add_cookie_header attrs = self._cookie_attrs(cookies) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Cellar/[email protected]/3.11.3/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/cookiejar.py", line 1329, in _cookie_attrs self.non_word_re.search(cookie.value) and version > 0): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: expected string or bytes-like object, got 'list' (.venv) v@V instagram_post %

README version numbering

The version numbering in the README are a little wack. Also it does not line up with the version numbers in setup.py

Links Not Being Able to send.

Hello there,
I want to send links by SMS and for some reason on TextNow it appears, but on my phone, it doesn't appear.

This is my code that doesn't work:

for number in phone_numbers:
    for result in range(result_count):
        link = f'https://www.themoviedb.org/movie/{content["results"][result]["id"]}'
        client.send_sms(number, link)

I am working on python version 3.9.9 && PyTextNow version 1.1.9 && Windows 10

Sudo

Program requires sudo in order to open and read/write the user_sids.json file.

Add Chrome Support

At the momment you need to have firefox to use this libbrary, that isnt ideal, i already have a half baked solution and ill put in a pull request and you can build on top of that

Status Code: 401

from pytextnow import TNAPI


client = TNAPI.Client("XXXXXXXXXX", cookie="sid")
client.auth_reset()
client.send_sms("+555 XXX XXXX", "Hello")
client.auth_reset()

Error 401

Open application tab and copy connect.sid cookie and paste it here.
connect.sid: XXXXX
Traceback (most recent call last):
File "c:\Users\User\Desktop\API\PyTextNow_API\pytextnow\sms.py", line 7, in
client.send_sms("+555 XXX XXXX", "Hello")
File "C:\Users\User\AppData\Local\Programs\Python\Python39\lib\site-packages\pytextnow\TNAPI.py", line 201, in send_sms
raise self.FailedRequest(str(response.status_code))
pytextnow.TNAPI.FailedRequest: Could not send message. server returned a Client error. Request Failed. Try resetting your authentication with client.auth_reset()
Status Code: 401

client.__login()

    client = pytextnow.Client('sdfds')
  File "C:\Users\emeri\Projects\Personal\PyTextNow_API\venv\lib\site-packages\pytextnow-2.0.0-py3.7.egg\pytextnow\TNAPI.py", line 29, in __init__
  File "C:\Users\emeri\Projects\Personal\PyTextNow_API\venv\lib\site-packages\pytextnow-2.0.0-py3.7.egg\pytextnow\TNAPI.py", line 317, in __get_sid
  File "C:\Users\emeri\Projects\Personal\PyTextNow_API\venv\lib\site-packages\pytextnow-2.0.0-py3.7.egg\pytextnow\TNAPI.py", line 307, in __login
AttributeError: 'Client' object has no attribute 'username'

cannot install

when i try to install with pip i receive answer pip install PyTextNow Collecting PyTextNow Could not find a version that satisfies the requirement PyTextNow (from versions: ) No matching distribution found for PyTextNow

and installing with git clone, when i run pip install -r requirements.txt i receive answer No matching distribution found for setuptools~=57.0.0 (from -r requirements.txt (line 2))

[Enhancement] Remove Selenium bot

One of the main issues with this is that it needs to use a Selenium bot with some extra hackery to try to bypass bot detection. As we know, this does not work very well and has even gotten @SilverStrings024 banned. I'm creating this issue as a place to add information and discuss how to make it work without needing the bot.

Anyone want to upgrade the robot? If not, it will be removed.

Hello everyone, sad news. Even though I tried to make the robot to lower the consumption of text now resources, the robot has gotten my hardware banned; likely because we tested too much but it's also possible that we messed up the configuration and made the robot easier to detect.

Now we either need to completely remove the robot, or someone else is going to need to take over the autonomous login/connect.sid harvesting. Without the robot or some other way to autonomously get the connect.sid cookie value, everyone will need to do it themselves (login, go into dev tools, etc). Mind you, your sid will likely change every time you log out or, sometimes, it changes on refresh or randomly so it's much more likely that your program will fail to send texts.

Sadly, the convenience of the robot getting the SID for us, logging back in if we were logged out, refreshing the page at random intervals, etc. is now an impossibility. If someone would like to write something to make it work, obfuscate it then put it in the package, please do!
Otherwise, I'm sorry to announce that fully autonomous login/sid harvesting is no longer viable. ๐Ÿ˜ž

Setup.py does not include project requirements

setup.py should have a section called install_requires that includes all the dependencies of the project. In this case

    install_requires=["requests >  2"]

requests > 2 in this case is just an example. This should be the version of requests that your package will not work if it is older than. Requests changed quite a bit in the 2.0 release so > 2 should work, but I have not tested it.

You should never lock a package dependencies to a specific version unless you absolutely have to. So don't do requests == 2.23.1 or anything like that.

Mimetypes Not Found

While running Python3 -m pip install -r requirements.txt. Error "mimetypes not found"

cannot install

when trying to install with "pip install PyTextNow".
i receive answer "Could not find a version that satisfies the requirement PyTextNow (from versions: )
No matching distribution found for PyTextNow"

No Module

Installed the latest TNAPI:
Successfully installed TNAPI-1.0.0 aiohttp-3.7.4.post0 async-timeout-3.0.1 attrs-20.3.0 multidict-5.1.0 yarl-1.6.3
Went to run code that included this line:
import TNAPI
Got:
ModuleNotFoundError: No module named 'TNAPI'
Tried lowercase:
ModuleNotFoundError: No module named 'tnapi'

Sending videos

Hi! I've made a Node.JS copycat of your project and am trying to implement it in something that allows people to watch a popular video platform over text message. I was wondering if in your research you happened to note what kinds of videos are accepted. I've been getting a 501 response when trying to upload mine. Have an excellent day! My repo: https://github.com/SpaceSaver/TN4NJS

Getting Status Code 520 when sending message

Hi all,

I have been using this for a few days and it was working fine generally, although sometimes I got 400 error. With a couple of tries, it would go through. However, I have been getting this error since last night and today I can't send any message out even though I signed in to the webpage and got a new sid_cookie_key and csrf_cookie_key. I tried to change the User Agent in the header and it didn't work too.

Did it get detected by TN? LOL

Thank you so much for your help. Really want to contribute to this project but don't know where to start.

Could not send message. server return a Server error. Request Failed.
Status Code: 520

Fix for media files errors on message

Problem

When an mp3 or other media not an image is in messages list, this cause critical error;

Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "C:\Users\level\AppData\Roaming\Python\Python39\site-packages\pytextnow\TNAPI.py", line 91, in on_exit
    unread_msgs = self.get_unread_messages()
  File "C:\Users\level\AppData\Roaming\Python\Python39\site-packages\pytextnow\TNAPI.py", line 186, in get_unread_messages
    new_messages = self.get_received_messages()
  File "C:\Users\level\AppData\Roaming\Python\Python39\site-packages\pytextnow\TNAPI.py", line 177, in get_received_messages
    messages = self.get_messages()
  File "C:\Users\level\AppData\Roaming\Python\Python39\site-packages\pytextnow\TNAPI.py", line 145, in get_messages
    messages = [
  File "C:\Users\level\AppData\Roaming\Python\Python39\site-packages\pytextnow\TNAPI.py", line 146, in <listcomp>
    Message(msg, self) if not msg["message"].startswith("http") else MultiMediaMessage(msg, self)
  File "C:\Users\level\AppData\Roaming\Python\Python39\site-packages\pytextnow\multi_media_message.py", line 12, in __init__
    try:
  File "C:\Program Files\Python39\lib\site-packages\requests\structures.py", line 54, in __getitem__
    return self._store[key.lower()][1]
KeyError: 'content-type'

Solution

In file pytextnow/multi_media_message.py
Replace

self.content_type = file_req.headers["Content-Type"]
self.extension = self.content_type.split("/")[1]

By this code

try:
    self.content_type = file_req.headers["Content-Type"]
    self.extension = self.content_type.split("/")[1]
except:
    pass

Anyone can help? - message not sent

Hi All,
First of all i would like to thank the developer for this script.
i am trying to make it work but i get the following error when trying to send.

Traceback (most recent call last):
File "", line 1, in
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pytextnow\TNAPI.py", line 272, in send_sms
self.request_handler(response.status_code)
File "C:\Users\Jonathan\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\LocalCache\local-packages\Python310\site-packages\pytextnow\TNAPI.py", line 315, in request_handler
raise FailedRequest(status_code)
pytextnow.error.FailedRequest: Could not send message. server return a Server error. Request Failed.
Status Code: 520

thanks

Stop the session

How can i stop the session without getting closing errors like this?
Exception ignored in atexit callback: <function Client.__init__.<locals>.on_exit at 0x000002A305B6FAC0> Traceback (most recent call last): File "C:\Program Files\Python310\lib\site-packages\pytextnow-1.2.0-py3.10.egg\pytextnow\TNAPI.py", line 96, in on_exit func(msg)

No module named PyTextNow

i installed the module with pip3, and when running the script with python myscript.py, i receive error
import PyTextNow
ImportError: No module named PyTextNow

Client.wait_for_response()

msg = client.wait_for_response("******8456")
Traceback (most recent call last):
File "", line 1, in
File "/home/pi/.local/lib/python3.10/site-packages/pytextnow/TNAPI.py", line 308, in wait_for_response
filtered = unread_msgs.get(number=number)
File "/home/pi/.local/lib/python3.10/site-packages/pytextnow/message_container.py", line 19, in get
return self.outer_self.MessageContainer(filtered_list, self.outer_self)
AttributeError: 'Client' object has no attribute 'MessageContainer'

Error

Everytime i try to run this code

import pytextnow as pytn
client = pytn.Client("jlaboy23", sid_cookie="s%3AIQTIp9fkmaNyFXgAnZTrhX0jS60TTTgG.MDUno6yJ9XRjnXc689g7NRk5YhlXyBYMQSQAX1%2F4DiQ", csrf_cookie="s%3AX_jgbWB_h6phng_eiTgL_cyd.e7zqr4zwkn5QMNZEI%2FWHF3XOHCEMAzyYYXu%2F4Nocc9A")

client.send_sms("Hi")

I get this error

Traceback (most recent call last):
  File "main.py", line 28, in <module>
    client = pytn.Client("jlaboy23", sid_cookie="s%3AIQTIp9fkmaNyFXgAnZTrhX0jS60TTTgG.MDUno6yJ9XRjnXc689g7NRk5YhlXyBYMQSQAX1%2F4DiQ", csrf_cookie="s%3AX_jgbWB_h6phng_eiTgL_cyd.e7zqr4zwkn5QMNZEI%2FWHF3XOHCEMAzyYYXu%2F4Nocc9A")
  File "/home/runner/phone-info/venv/lib/python3.8/site-packages/pytextnow/TNAPI.py", line 36, in __init__
    with open(self._user_cookies_file, 'r') as file:
FileNotFoundError: [Errno 2] No such file or directory: '/home/runner/.cache/pip/pool/de/53/e4/user_cookies.json'

I dont understand why can someone help me.

Cookie expiration?

Do the textnow cookies expire? Is there a way the client can auto-refresh them?

Exception: KeyError: 'content-type'

So I'm getting the error "KeyError: 'content-type'" when I try to get unread messages. I have always used PyTextNow and I know for a fact that this has worked before, but now it isn't. Can someone tell me why, even though this project hasn't been updated in a while?

issue with get_user()

client = pytextnow.Client('sdfds')
File "C:\Users\emeri\Projects\Personal\PyTextNow_API\venv\lib\site-packages\pytextnow-2.0.0-py3.7.egg\pytextnow\TNAPI.py", line 33, in __init__
File "C:\Users\emeri\Projects\Personal\PyTextNow_API\venv\lib\site-packages\pytextnow-2.0.0-py3.7.egg\pytextnow\database\db.py", line 538, in get_user
AttributeError: 'list' object has no attribute 'first'

to recreate..
create a pytextnow.Client() instance and give it a random client.

Fail on dateutil

I installed PyTextNow to use in an app running on a Raspberry Pi 3A+, Python 3. I first took an error that the dateutil library was not found. I installed dateutil and now I get the following error. Suggestions to fix?

%Run main.py
Traceback (most recent call last):
File "/home/pi/clearskyalarm/main.py", line 10, in
import pytextnow as pytn
File "/home/pi/.local/lib/python3.7/site-packages/pytextnow/init.py", line 2, in
from pytextnow.TNAPI import *
File "/home/pi/.local/lib/python3.7/site-packages/pytextnow/TNAPI.py", line 8, in
from dateutil.relativedelta import relativedelta
File "/home/pi/.local/lib/python3.7/site-packages/dateutil/relativedelta.py", line 118
raise TypeError, "relativedelta only diffs datetime/date"
^
SyntaxError: invalid syntax

calling

is there a way that sending an mp3 file over voice call or sip is possible?
or a way to pipe audio into the program?

or vice versa and answer or decline calls?

Exceptions on failed message delivery

Hello, I love this package but I was wondering if there would be an exception raised if a message fails to be delivered or will it just raise a FailedRequestException?
If there is no exception for a failed message, I'd be happy to try and write up a PR for it.

Multiple lines

When I try to send something like this

client.send_sms(number, "hi\n")
or
client.send_sms(number, """hi
hi""")
I get an error
Is this supposed to happen? Or can you just not use multiple lines in a message.

Status Code: 400 "Could not send message."

After sending one message with the new 1.1.8 update, started getting the "Could not send message." error again. Tried resetting auth, logged in and out and replaced the new cookies. Still didn't work.

Also, when I installed with pip no "user_cookies.json" file was included in the package. Had to add it myself, not sure if this is a problem on my end or not.

Here's the simple program I used:

import pytextnow
import os

sid = os.environ['sid']
csrf = os.environ['csrf']
number = os.environ['number']

client = pytextnow.Client("is037412", sid_cookie=sid, csrf_cookie=csrf)

client.send_sms(number, "Hello World!")

Can you make this to send to multiple numbers?

I want to use it for marketing, If you can please make a video how to use it (where I put the numbers, message, username, cookie, sid and what is the command to run it. (I'm new on this python, but your project sound very interesting) I will wait your answer. You can contact me directly at: [email protected] Thank you so much

issue sending sms

I have an issue sending sms. In wich path do i need to be to execute the send sms command and also what is the full command to send an sms. thank you

Anyone Want to help with VOIP?

In the branch unstable-pre-release-2.1.0 we're implementing VOIP.
If you have the ability to work with VOIP and want to, we'd love to see you submit a PR or two to help get it stable. If you do choose to work on the VOIP, please tag me and ask to be brought into the Discord so we can discuss your ideas and changes with the team and implement it in a way that keeps the package stable.

Note that in the unstable-pre-release-2.0.0 branch, we're completely removing ALL references to VOIP so, if you want to work on it, you'll need to use unstable-pre-release-2.1.0

Thank you for any help!

Issue Sending Messages

I am having issues trying to send someone a message with the new line character (\n).

For example, if the content of the message is "Hello World", the message gets sent. However, if the content of the message we want to send is "Hello\nWorld", then I get the following error message:

pytextnow.error.FailedRequest: Could not send message. server returned a Client error. Request Failed. Try resetting your authentication with client.auth_reset()
Status Code: 400

error 503 with ips

When i tried run code. i got 503 error
Can you support with proxy
thank you very much

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.