4

Now the API can read anything post-related!

The new endpoints are getPost and getPostComments, plus a sightly revised getPostList. They're all documented on the API page, but you can ask us on IRC if you have any problems.

Here's a small example script (in python) that will print the title of every post in /all/new and whether jobes has commented on them

import requests
posts = requests.get('https://phuks.co/api/getPostList/all/new').json()
for post in posts['posts']:
    comments = requests.get('https://phuks.co/api/getPostComments/' + str(post['pid'])).json()
    jobesHasPosted = False
    for comm in comments['comments']:
        if comm['user'] == "jobes":
            jobesHasPosted = True
            break
    print("Post", post['pid'], "Title", post['title'], "JobesPosted:", jobesHasPosted)
Now the API can read anything post-related! The new endpoints are `getPost` and `getPostComments`, plus a sightly revised `getPostList`. They're all documented on the [API page](https://phuks.co/api), but you can ask us on IRC if you have any problems. Here's a small example script (in python) that will print the title of every post in /all/new and whether jobes has commented on them ``` import requests posts = requests.get('https://phuks.co/api/getPostList/all/new').json() for post in posts['posts']: comments = requests.get('https://phuks.co/api/getPostComments/' + str(post['pid'])).json() jobesHasPosted = False for comm in comments['comments']: if comm['user'] == "jobes": jobesHasPosted = True break print("Post", post['pid'], "Title", post['title'], "JobesPosted:", jobesHasPosted) ```

3 comments

[–] pembo210 0 points (+0|-0)
import requests

res = requests.get('https://phuks.co/api/getPostList/all/new').json()

for post in res['posts']:
    print ('--------')
    print ('title: ' + post['title'])
    print ('comments: ' + str(post['comments']))
    print ('link: https://phuks.co/s/' + post['sub'] + '/' + str(post['pid']))

all new response - https://i.imgur.com/UWvfty7.png

[–] CDanger 0 points (+0|-0)

Great job! This is really helpful for our backup and analytics work.