Snapchat API raising error - python

I am currently experimenting with a python API for Snapchat that was derived from the PHP API. I am running my program from a Windows 10 laptop from Asus. It seems that I am getting a consistent error that is telling me I need to update my software OS or update Snapchat, which is weird because I have the latest version of windows and there is no Snapchat on windows.
After researching the problem, it seemed it was a common message given on jailbroken phones in an attempt to counter third party developers. It seems that I am the only one having this problem, as I looked around the internet and no one else seemed to complain. Could Someone please help me get around this issue and explain why this is occurring? Thank you in advance
>>> import pysnap
>>> snapchat = pysnap.Snapchat()
>>> snapchat.login('username', 'password')
Traceback (most recent call last):
File "<pyshell#13>", line 1, in <module>
snapchat().login('username', 'password')
File "build\bdist.win32\egg\pysnap\__init__.py", line 113, in login
raise Exception(result.get('message', 'unknown error'))
Exception: You're using a version of Snapchat or operating system that's no longer supported. Please upgrade your device's operating system and update to the newest app version to use Snapchat. Thanks!

I don't know that I have a solution, but it looks like several similar libraries have dealt with problems as well:
SnapchatBot
https://github.com/agermanidis/SnapchatBot/issues/52
Snapchat PHP SDK
https://github.com/liamcottle/Snapchat-SDK-PHP/issues/38
It does look as though the PHP SDK solved the problem, though it doesn't look like the solution is explicitly stated there.

Related

pyFirmata gives error: module 'inspect' has no attribute 'getargspec'

I'm trying to use pyFirmata, but I can't get it to work. Even the most basic of the library does not work. I guess there is something wrong with the library code.
from pyfirmata import Arduino,util
import time
port = 'COM5'
board = Arduino(port)
I get this error:
Traceback (most recent call last):
File "c:\Users\Public\pythonpublic\arduino.py", line 5, in <module>
board = Arduino(port)
^^^^^^^^^^^^^
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\__init__.py", line 19, in __init__
super(Arduino, self).__init__(*args, **kwargs)
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\pyfirmata.py", line 101, in __init__
self.setup_layout(layout)
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\pyfirmata.py", line 157, in setup_layout
self._set_default_handlers()
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\pyfirmata.py", line 161, in _set_default_handlers
self.add_cmd_handler(ANALOG_MESSAGE, self._handle_analog_message)
File "C:\Users\marce\AppData\Roaming\Python\Python311\site-packages\pyfirmata\pyfirmata.py", line 185, in add_cmd_handler
len_args = len(inspect.getargspec(func)[0])
^^^^^^^^^^^^^^^^^^
AttributeError: module 'inspect' has no attribute 'getargspec'. Did you mean: 'getargs'?
As already pointed out in another answer, the pyFirmata modules is currently documented to run on Python 2.7, 3.6 and 3.7. This doesn't mean it won't work on other versions, but probably that it hasn't been tested on other versions by the author and it isn't officially supported. So it may or may not work on newer Python versions.
Your error message is caused by a missing function inspect.getargspec(). This function is part of the Python Standard Library, but has been deprecated since Python 3.0 (which came out in 2008). Unfortunately the author wasn't aware of this or simply didn't bother to fix it, so now the code doesn't work anymore with the latest version of Python.
In the Python documentation, you can see that the function is still available in version 3.10, but not in version 3.11.
To solve this you have a number of options:
Downgrade to Python 3.10, which is currently still a good option (Python 3.10 is "alive" until 2026-10-04). I don't know if all other functionality does work. I guess it will, but you would have to find out yourself.
Downgrade to Python 3.7, which is claimed to be supported. Given that Python 3.7 is also still alive (until 2023-06-27), that's a reasonable option as well.
Create an issue for the pyFirmata module and hope the author will fix the problem. Note that an issue has already been created by someone in 2019 but apparently without effect. You could leave a comment there confirming that this has now broken for real.
Clone the library and fix it yourself (and create a Pull Request to get it in the official library).
Find another, similar, library that does work with Python 3.11.
Write the code yourself.
Downgrading to a Python version between 3.7 and 3.10 is certainly the simplest option, and leaving some feedback to the author will give you a chance it will be fixed in the future, in case your planning to use your script for a longer time.
According to the first line of pyFirmata docs:
It runs on Python 2.7, 3.6 and 3.7
You are using Python 3.11. The inspect (core library module) has changed since Python 3.7.

Read Gmail messages using Python script as a cronjob

I'm having a problem accessing Gmail account. Currently, I'm using this library written in python 2.7+ to log in and to read Gmail messages. To use the library, I had to enable Google 'insecure app'. Everything is working fine with this lib.
Now, I'm moving to python 3+, and I cannot use the lib anymore. Whenever I import the lib, it throws the following error:
import gmail
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python3.6/site-packages/gmail-0.0.5-py3.6.egg/gmail/__init__.py", line 16, in <module>
File "/usr/local/lib/python3.6/site-packages/gmail-0.0.5-py3.6.egg/gmail/gmail.py", line 5, in <module>
ModuleNotFoundError: No module named 'utf'
I tried to overcome this problem by looking at a replacement module for 'utf' in python 3+ but I couldn't figure out what it is. How can I fix that?
Another problem is that I tried the official python lib provided by Google. Here is the link for the tutorial. I successfully completed the quick start example, but the script opened my browser, and I had to allow the access via the browser. In fact, I just want to create a cronjob to run my script periodically on my server without an UI. Does Google allow it?
Thank you very much.
The official API for Gmail that works in python 3
and there are a lot of guides for using it, for example:
https://github.com/abhishekchhibber/Gmail-Api-through-Python
But if you feel this is too complicated (I do), instead you may want to activate access using POP3 or IMAP from the Gmail settings panel.
Then use poplib or imaplib.
Example: https://docs.python.org/3/library/poplib.html#pop3-example
This is in general easier, more portable and uses packages already found in default python installs.
Edit:
The library you were using used IMAP access, not oauth.
Also to answer your "UTF" question: every string in python 3 is UTF8 by default, if you want to decode raw data, you should use 'mystring'.decode('utf-7'), etc.
Edit 2: looks like someone already did the work: https://github.com/charlierguo/gmail/pull/48
OK, I just saw the problem in the instructions:
So, I guess your only alternative is to stick with POP3/IMAP (which your program was already using).

PRAW: Python Reddit API Wrapper not working

I'm trying to make a Reddit bot, except I cannot even use the following simple example, nor the examples PRAW has in their docs.
The following code
import praw
r = praw.Reddit(user_agent="some useragent text")
r.login()
returns the following error
Traceback (most recent call last):
File "savageAxeBot.py", line 3, in <module>
r = praw.Reddit(user_agent="some useragent text")
File "/Library/Python/2.7/site-packages/praw-4.0.0b21-py2.7.egg/praw/reddit.py", line 101, in __init__
raise ClientException(required_message.format(attribute))
praw.exceptions.ClientException: Required configuration setting 'client_id' missing.
This setting can be provided in a praw.ini file, as a keyword argument to the `Reddit` class constructor, or as an environment variable.
UPDATE: I've gotten both my client ID and secret. I managed to get the above code (exactly as shown) to work on Fedora 24, not could not get it to work on either Raspbian or Mac OS X.
PRAW seems easier to use from python than the Reddit API, so I would prefer to stick with it. Also, it appears that login() is depreciated, so how can I use OAuth2 (or whatever it is called)?
Note: I installed PRAW using easy_install praw, since pip install praw wasn't working. I tried using pip on both Mac OS X 10.12 and Raspbian, and neither worked. Any ideas?
[Promoted/expanded from a comment]
As pointed out by #bboe, the PRAW docs can be located here ¹.
Specifically, you want the Getting Started ¹ page which walks you through instantiating a Reddit object in read-only or read/write mode.
¹ PRAW 4 documentation is no longer available onlne, so I've updated the links to track the latest version.

Scapy sniff() "an operation was performed on something that is not a socket"

I recently installed scapy and was trying to start using it and I'm having trouble using the sniff() function.
I've been able to install Scapy using the steps described in their docs. I'm running Windows 7 x64 and using Python 2.6. I'm able to use the send family of functions fine (confirmed with Wireshark) but sniff() is failing with the following stack trace:
Traceback (most recent call last):
File "sniffingStuff.py", line 11, in <module>
sniff(filter="ip",prn=customAction)
File "C:\Python26\lib\site-packages\scapy\sendrecv.py", line 575, in sniff
sel = select([s],[],[],remain)
select.error: (10038, 'An operation was attempted on something that is not a socket')
The only thing off the top of my head that I thought might be wrong is that I had PCAP installed already because I had Wireshark installed. I looked around and didn't see any useful answers.
Edit: Since I didn't make this clear in my original post, any calls to the sniff function fails, regardless of parameters, filters, etc. For a concrete reference see here.
Thanks
I believe that scapy requires a specific version of WinPCAP as per the instructions for installation. Check the Windows installation guide here for supported version information.

Python2.5, smtplib and KeyError

I'm trying to write a python script for BusyBox on ESXi with mail functionality. It runs Python 2.5 with some libraries missing (i.e. the smtplib). I downloaded Python2.5 sources and copied the lib-folder to ESXi. Now I am trying to import the smtplib via "import lib.smtplib" but Python says:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/pysexi/lib/smtplib.py", line 46, in <module>
import email.Utils
File "/pysexi/lib/email/__init__.py", line 115, in <module>
setattr(sys.modules['email'], _name, importer)
KeyError: 'email'
I'm stuck. So every help and every thought is appreciated!
Trying to install generic applications on an appliance or custom OS is always fun.
Just a guess, but it may be that the email lib is a compiled C module - i.e. not pure python.
I would try use libraries that are as completely python with no compiled code - I don't know if there are pure python versions of the libraries.
The option is to try to track down what OS version that ESXi is based on and then use the matching python version from that OS.
I don't know anything about BusyBox or ESXi - therefore this may be more of a suggestion than an answer, but you might consider using a email service that supports an HTTP or RESTful API - such as MailGun. They have a free plan for up to 200 emails a day, so it might not cost you anything.
Again, this way be more of a suggestion or a plan "B" (if no one can help you with this specific problem)

Categories