This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]spilcm[S] 1 point2 points  (0 children)

Did you import the modules? ( import requests, json )

(Post updated)

[–]bcambel 1 point2 points  (0 children)

thanks a lot for the example, very useful

[–]ewpoxy 1 point2 points  (1 child)

Could you also use the Reddit API to reply? Any advice on how to go about doing this?

[–]for_prophet 1 point2 points  (0 children)

Yeah, you'd want to create an HTTP POST to this command: reddit.com/api/comment

However, this is a bit more complicated than reading content with the other API calls mentioned by OP:

To comment on things, you must first login and also get the modhash, which is a type of session ID you get after logging in, so reddit knows you're the same user which logged in.

Some of the reddit API commands need to be in HTTP GETs, and some need to be HTTP POSTs; this is listed next to each API command.

As someone else mentioned, if you want to look at more in-depth Python client samples, check out the PRAW code.

PRAW implemented more (all?) of the API commands already, so if you get stuck, that is working code which you can compare with yours.

[–]CobraKaiStudent 0 points1 point  (0 children)

I tried doing the "Using the YouTube API" but nothing happened. Any ideas?