Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
liushooter committed Aug 7, 2020
1 parent cdb4122 commit 2d7c421
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
4 changes: 3 additions & 1 deletion wp.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions wp.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import json
import requests

end_point_url_posts ="http://rebase.network/wp-json/wp/v2/posts"
end_point_url_posts ="https://rebase.network/wp-json/wp/v2/posts"
web3_excel_url = "https://sheet.best/api/sheets/c904c7be-955d-429e-9c29-376f4e31ecca"

def get_web3_content(url):
Expand Down Expand Up @@ -36,9 +36,9 @@ def create_wp_post(u_id, u_passwd, p_author, p_title, p_content):
# 以下内容不用修改
p_status = "publish" # 直接发布
p_format = "gallery" # 展示方式
p_featured_media = "647" # 封面图片的id
p_featured_media = "1012" # 封面图片的id
p_categories = "27" # 类别id

p_tags = [30,32,31,28]
payload = {
'title': p_title,
'content' : p_content,
Expand All @@ -47,13 +47,14 @@ def create_wp_post(u_id, u_passwd, p_author, p_title, p_content):
'format': p_format,
'featured_media' : p_featured_media,
'categories' : p_categories,
'tags': p_tags,
}

headers = {'content-type': "Application/json"}

resp = requests.post(end_point_url_posts, auth=(u_id, u_passwd), headers=headers, data=json.dumps(payload))
result = json.loads(resp.text)

# print(resp.text)
print(result["permalink_template"])

def get_content():
Expand Down Expand Up @@ -101,8 +102,7 @@ def get_content():

create_wp_post(u_id, u_passwd, p_author, p_title, p_content)

# https://www.yannyann.site/2018/09/wp-rest-api-create-new-post-and-upload-image/
# https://www.yannyann.com/2018/09/wp-rest-api-create-new-post-and-upload-image/
# https://gist.githubusercontent.com/a2d8a4v/ecb2843621aa9f5287b1b2a6c0c6e400/raw/4b405917e6eeede6ddab78f88191c58c6d5f8055/WP%20REST%20API%20by%20Python%203.5%20-%20Create%20a%20new%20post
# https://developer.wordpress.org/rest-api/reference/posts/#create-a-post
# http://www.bagualu.net/wordpress/archives/5408
# https://github.com/liushooter/google-appscript#%E4%BA%A7%E5%93%81

0 comments on commit 2d7c421

Please sign in to comment.