Thursday, December 1, 2022
HomeWordPress DevelopmentHow do you fetch the authors e-mail or IP from /feedback? (REST...

How do you fetch the authors e-mail or IP from /feedback? (REST API)


Does anybody know how you can get the e-mail and IP for WordPress feedback utilizing the REST API? The docs. Are the fields simply not offered within the response? “author_url” is there. However not “author_email” and many others.

import requests
import json
import base64

wordpress_user = "xxx"
wordpress_password = "xA5t xcxN xmxK nxyx Fxgx OxKx"
wordpress_credentials = wordpress_user + ":" + wordpress_password
wordpress_token = base64.b64encode(wordpress_credentials.encode())
wordpress_header = {'Authorization': 'Primary ' + wordpress_token.decode('utf-8')}

api_url="https://[site-here].com/wp-json/wp/v2/feedback?standing=all"
response = requests.get(api_url, headers = wordpress_header)
response_json = response.json()
if ( response.status_code == 200 ):
    #
    approved_comments_list = []
    unapproved_comments_list = []   
    for j in response_json:
        if j['status'] == 'authorised':
            approved_comments_list.append(j)
        elif j['status'] == 'maintain':
            unapproved_comments_list.append(j)

for j in unapproved_comments_list:
    comment_url="https://x.com/wp-json/wp/v2/feedback/" + str(j['id'])
    response = requests.get(comment_url, headers = wordpress_header)
    response_json = response.json()
    print(json.dumps(response_json, indent=4))

Output:

{
    "id": 122,
    "put up": 560,
    "dad or mum": 0,
    "creator": 0,
    "author_name": "jeff",
    "author_url": "",
    "date": "2022-11-30T20:50:24",
    "date_gmt": "2022-11-30T20:50:24",
    "content material": {
        "rendered": "<p>yo dawg. you suck lol</p>n"
    },
    "hyperlink": "https://x.com/hello-world/comment-page-1/#comment-122",
    "standing": "maintain",
    "kind": "remark",
    "meta": [],
    "_links": {
        "self": [
            {
                "href": "https://x.com/wp-json/wp/v2/comments/122"
            }
        ],
        "assortment": [
            {
                "href": "https://x.com/wp-json/wp/v2/comments"
            }
        ],
        "up": [
            {
                "embeddable": true,
                "post_type": "post",
                "href": "https://x.com/wp-json/wp/v2/posts/560"
            }
        ]
    } }

enter image description here

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments