Comments (13)
If I remember correctly hfaran wrote a blog post about it. He basically did some reverse engineering. You should be able to do it through dev tools on Chrome/network section. When I wrote the duplicate feature I actually dig through the js source code, which was not fun...
from piazza-api.
Seems like a challenge. I'll try and take a look when I have time.
from piazza-api.
I think I figured out the issue!
Here we go:
- I was able to replicate the issue by installing it with
pip install piazza-api
with Python 3 - It turns out doing the above installed piazza-api 0.5.2. This happened because it looks like for the past few releases I've only been pushing py2 wheels for some reason, if someone was using py3, they would get the old version 0.5.2, which was the last that had the py3 wheel and/or sdist. 🤦♂️
- Anyways, I just pushed sdist and bdist_wheel for py3 for versions 0.8.0 and 0.9.0 so now py3 users should get the newest version with working authentication.
TL;DR: please try upgrading your version of piazza-api (pip install -U piazza-api
) and trying again. It should work now. 😄
from piazza-api.
I'm running into a similar issue with get_user_classes()
, with the following trace:
File "C:\Program Files\Python36\lib\site-packages\piazza_api\piazza.py", line 54, in get_user_profile
return self._rpc_api.get_user_profile()
piazza_api.exceptions.RequestError: Could not get user profile.
Response: {
"result": null,
"error_codes": [],
"error": "Request not valid",
"aid": "jpnibouggjc3u1"
}
from piazza-api.
Unfortunately, I think the maintainer has abandoned this project.
from piazza-api.
I'm happy to accept any changes if someone finds out what has changed in the API but unfortunately I don't have much free time lately to investigate it myself.
from piazza-api.
I'd be willing to take a look. How did you "discover' this API originally? Was this just a reverse engineering effort?
from piazza-api.
Alright, this took me far longer than I would have liked but I was finally able to dig up the old blog post (my site has been down for a while and I hadn't migrated the content to anywhere - had to dig up an old tarsnap key, wait while it took forever to download the archive, look through the Ghost sqlite DB and finally got the text).
Anyways, here it is: https://hfaran.github.io/posts/reverse-engineering-piazzas-api/
TL;DR: you can just open up Fiddler or dev tools in your favorite browser and see what API calls are made, and just experiment with them until you get it right. 😄
from piazza-api.
Also, for what it's worth I just tried out all three of the methods you guys listed above and they're all working for me...
In [19]: len(list(eece210.iter_all_posts(limit=10)))
Out[19]: 10
In [20]: len(eece210.get_post(100))
Out[20]: 31
In [21]: len(p.get_user_classes())
Out[21]: 14
So yeah, I'm not sure what's up with your guys' usages. Maybe Piazza has changed something internally and it works for my account and not yours? I've been out of school for a couple years now so I haven't used Piazza in a while, and all my testing is done with classes that are >5 years old now.
from piazza-api.
It would help if you can give me the exact steps you're taking when running into the issue (i.e., include a screenshot or copy/paste all the commands you're running in IPython or whatever)
from piazza-api.
Thanks for coming back to this project!
I had all my code in a single file:
from piazza_api import Piazza
import json
from datetime import datetime
import time
p = Piazza()
p.user_login(email = "", password="")
courses = p.get_user_classes() #This broke for some reason
for course in courses:
courseInfo = course["name"] + " " + course["num"]
print(courseInfo)
courseId = course["nid"]
courseForum = p.network(courseId)
coursePosts = courseForum.iter_all_posts()
for post in coursePosts:
pst = str(post)+"\n"
pst = pst.encode('utf8')
#write to file
This errored out when I tried to retrieve the courses.
Traceback (most recent call last):
...
courses = p.get_user_classes()
...
piazza_api.exceptions.RequestError: Could not get user profile.
Response: {
"result": null,
"error_codes": [],
"error": "Request not valid",
"aid": "jpnibouggjc3u1"
}
When I tried overriding courses to be a list of dicts, like this:
courses = [
{"name": name,
"num": num,
"nid": nid}
]
I get the error
Traceback (most recent call last):
...
for post in coursePosts:
...
piazza_api.exceptions.RequestError: Could not retrieve your feed.
Response: {
"result": null,
"error_codes": [],
"error": "Request not valid",
"aid": "jpoccv8fta93ja"
}```
from piazza-api.
I guess that the user just isn't being logged in properly. Can I ask how the user.login method was found? I couldn't find the method when using chrome dev tools.
from piazza-api.
@dXu23 The authentication method was actually found here https://gist.github.com/alexjlockwood/6797443. Authentication was the one thing that I (thankfully) didn't need to reverse engineer.
from piazza-api.
Related Issues (20)
- Upload to PyPI HOT 1
- Create Sphinx documentation
- Refactor Piazza class into something more user-friendly
- Tests with responses HOT 2
- Setup CI with Travis-CI
- Setup coverage with coveralls
- Investigate reverse-engineering API further HOT 8
- ImportError: no module named 'requests' HOT 4
- Figure out how to use the network apis HOT 4
- get_all_users( ) not working HOT 3
- Add mark as duplicate functionality HOT 1
- There are no docs, the sphinx build also has 404 error when clicking module index HOT 1
- Is there a way to retrieve posts that are only unread?
- Release a new version with most recent commits made? HOT 2
- Unable to login with p.user_login() HOT 7
- login failing "Email or password incorrect" HOT 9
- Update post not working with new piazza api
- Make this an actual package and add setuptools goodness etc.
- readthedocs
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from piazza-api.