可以更改主题的时间戳吗?

我想更改主题的时间戳,找到了这个 API

但是,它出现了“Bad CSRF”错误,有人能给点提示吗?谢谢

import requests

# 错误的 headers
headers = {
    "Authorization": f"Apikey {api_key}",
    "User-Agent": api_username
}

# 正确的
headers = {"Content-Type": "application/json; charset=utf-8", "Api-Key": api_key, "Api-Username": api_username }

# 修改帖子日期
created_at = "1701417600"
update_data = {"timestamp": created_at}
response = requests.put(f"https://www.mysite.com/t/6532/change-timestamp.json", json=update_data, headers=headers)

print(response.status_code)   # 403
print(response.text)     # '["BAD CSRF"]'
print(response.json())   # ['BAD CSRF']

这些不是正确的标头:

获得 API 密钥后,您可以像这样将其与 API 用户名一起作为 HTTP 标头传递:

curl -X GET "http://127.0.0.1:3000/admin/users/list/active.json" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system"

POST 请求将如下所示:

curl -X POST "http://127.0.0.1:3000/categories" \
-H "Content-Type: multipart/form-data;" \
-H "Api-Key: 714552c6148e1617aeab526d0606184b94a80ec048fc09894ff1a72b740c5f19" \
-H "Api-Username: system" \
-F "name=89853c20-4409-e91a-a8ea-f6cdff96aaaa" \
-F "color=49d9e9" \
-F "text_color=f0fcfd"
2 个赞

谢谢 @Firepup650
我的错,是的,那个请求头是错误的,上面我贴出了正确的请求头,它能正常工作。

1 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.