Giter VIP home page Giter VIP logo

Comments (13)

LithiumH avatar LithiumH commented on July 28, 2024 1

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.

ktrieu avatar ktrieu commented on July 28, 2024 1

Seems like a challenge. I'll try and take a look when I have time.

from piazza-api.

hfaran avatar hfaran commented on July 28, 2024 1

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.

Piezoelectric avatar Piezoelectric commented on July 28, 2024

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.

ktrieu avatar ktrieu commented on July 28, 2024

Unfortunately, I think the maintainer has abandoned this project.

from piazza-api.

hfaran avatar hfaran commented on July 28, 2024

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.

ktrieu avatar ktrieu commented on July 28, 2024

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.

hfaran avatar hfaran commented on July 28, 2024

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.

hfaran avatar hfaran commented on July 28, 2024

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.

hfaran avatar hfaran commented on July 28, 2024

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.

Piezoelectric avatar Piezoelectric commented on July 28, 2024

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.

dXu23 avatar dXu23 commented on July 28, 2024

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.

hfaran avatar hfaran commented on July 28, 2024

@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)

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.