如何从Wordpress Page REST API获取自定义属性?

时间:2019-09-05 07:20:17

标签: wordpress wordpress-rest-api

我使用https://developer.wordpress.org/rest-api/reference/pages/ API来读取Android Page上的页面。我需要知道 json shema看起来像这样:

{
  "definitions": {},
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "http://example.com/root.json",
  "type": "object",
  "title": "The Root Schema",
  "required": [
    "id",
    "date",
    "date_gmt",
    "guid",
    "modified",
    "modified_gmt",
    "slug",
    "status",
    "type",
    "link",
    "title",
    "content",
    "excerpt",
    "author",
    "featured_media",
    "parent",
    "menu_order",
    "comment_status",
    "ping_status",
    "template",
    "meta",
    "categories",
    "tags",
    "_links"
  ],
  "properties": {
    "id": {
      "$id": "#/properties/id",
      "type": "integer",
      "title": "The Id Schema",
      "default": 0,
      "examples": [
        793
      ]
    },
    "date": {
      "$id": "#/properties/date",
      "type": "string",
      "title": "The Date Schema",
      "default": "",
      "examples": [
        "2018-07-01T11:57:51"
      ],
      "pattern": "^(.*)$"
    },
    "date_gmt": {
      "$id": "#/properties/date_gmt",
      "type": "string",
      "title": "The Date_gmt Schema",
      "default": "",
      "examples": [
        "2018-07-01T11:57:51"
      ],
      "pattern": "^(.*)$"
    },
    "guid": {
      "$id": "#/properties/guid",
      "type": "object",
      "title": "The Guid Schema",
      "required": [
        "rendered"
      ],
      "properties": {
        "rendered": {
          "$id": "#/properties/guid/properties/rendered",
          "type": "string",
          "title": "The Rendered Schema",
          "default": "",
          "examples": [
            "https://test.com/?page_id=793"
          ],
          "pattern": "^(.*)$"
        }
      }
    },
    "modified": {
      "$id": "#/properties/modified",
      "type": "string",
      "title": "The Modified Schema",
      "default": "",
      "examples": [
        "2018-07-01T11:57:51"
      ],
      "pattern": "^(.*)$"
    },
    "modified_gmt": {
      "$id": "#/properties/modified_gmt",
      "type": "string",
      "title": "The Modified_gmt Schema",
      "default": "",
      "examples": [
        "2018-07-01T11:57:51"
      ],
      "pattern": "^(.*)$"
    },
    "slug": {
      "$id": "#/properties/slug",
      "type": "string",
      "title": "The Slug Schema",
      "default": "",
      "examples": [
        "about-blank"
      ],
      "pattern": "^(.*)$"
    },
    "status": {
      "$id": "#/properties/status",
      "type": "string",
      "title": "The Status Schema",
      "default": "",
      "examples": [
        "publish"
      ],
      "pattern": "^(.*)$"
    },
    "type": {
      "$id": "#/properties/type",
      "type": "string",
      "title": "The Type Schema",
      "default": "",
      "examples": [
        "page"
      ],
      "pattern": "^(.*)$"
    },
    "link": {
      "$id": "#/properties/link",
      "type": "string",
      "title": "The Link Schema",
      "default": "",
      "examples": [
        "https://test.com/test/test/test-blank/"
      ],
      "pattern": "^(.*)$"
    },
    "title": {
      "$id": "#/properties/title",
      "type": "object",
      "title": "The Title Schema",
      "required": [
        "rendered"
      ],
      "properties": {
        "rendered": {
          "$id": "#/properties/title/properties/rendered",
          "type": "string",
          "title": "The Rendered Schema",
          "default": "",
          "examples": [
            "://test blank"
          ],
          "pattern": "^(.*)$"
        }
      }
    },
    "content": {
      "$id": "#/properties/content",
      "type": "object",
      "title": "The Content Schema",
      "required": [
        "rendered",
        "protected"
      ],
      "properties": {
        "rendered": {
          "$id": "#/properties/content/properties/rendered",
          "type": "string",
          "title": "The Rendered Schema",
          "default": "",
          "examples": [
            "ssss"
          ],
          "pattern": "^(.*)$"
        },
        "protected": {
          "$id": "#/properties/content/properties/protected",
          "type": "boolean",
          "title": "The Protected Schema",
          "default": false,
          "examples": [
            false
          ]
        }
      }
    },
    "excerpt": {
      "$id": "#/properties/excerpt",
      "type": "object",
      "title": "The Excerpt Schema",
      "required": [
        "rendered",
        "protected"
      ],
      "properties": {
        "rendered": {
          "$id": "#/properties/excerpt/properties/rendered",
          "type": "string",
          "title": "The Rendered Schema",
          "default": "",
          "examples": [
            "hi"
          ],
          "pattern": "^(.*)$"
        },
        "protected": {
          "$id": "#/properties/excerpt/properties/protected",
          "type": "boolean",
          "title": "The Protected Schema",
          "default": false,
          "examples": [
            false
          ]
        }
      }
    },
    "author": {
      "$id": "#/properties/author",
      "type": "integer",
      "title": "The Author Schema",
      "default": 0,
      "examples": [
        1
      ]
    },
    "featured_media": {
      "$id": "#/properties/featured_media",
      "type": "integer",
      "title": "The Featured_media Schema",
      "default": 0,
      "examples": [
        794
      ]
    },
    "parent": {
      "$id": "#/properties/parent",
      "type": "integer",
      "title": "The Parent Schema",
      "default": 0,
      "examples": [
        525
      ]
    },
    "menu_order": {
      "$id": "#/properties/menu_order",
      "type": "integer",
      "title": "The Menu_order Schema",
      "default": 0,
      "examples": [
        0
      ]
    },
    "comment_status": {
      "$id": "#/properties/comment_status",
      "type": "string",
      "title": "The Comment_status Schema",
      "default": "",
      "examples": [
        "closed"
      ],
      "pattern": "^(.*)$"
    },
    "ping_status": {
      "$id": "#/properties/ping_status",
      "type": "string",
      "title": "The Ping_status Schema",
      "default": "",
      "examples": [
        "closed"
      ],
      "pattern": "^(.*)$"
    },
    "template": {
      "$id": "#/properties/template",
      "type": "string",
      "title": "The Template Schema",
      "default": "",
      "examples": [
        "test.php"
      ],
      "pattern": "^(.*)$"
    },
    "meta": {
      "$id": "#/properties/meta",
      "type": "object",
      "title": "The Meta Schema",
      "required": [
        "ngg_post_thumbnail",
        "pmpro_default_level",
        "spay_email"
      ],
      "properties": {
        "ngg_post_thumbnail": {
          "$id": "#/properties/meta/properties/ngg_post_thumbnail",
          "type": "integer",
          "title": "The Ngg_post_thumbnail Schema",
          "default": 0,
          "examples": [
            0
          ]
        },
        "pmpro_default_level": {
          "$id": "#/properties/meta/properties/pmpro_default_level",
          "type": "integer",
          "title": "The Pmpro_default_level Schema",
          "default": 0,
          "examples": [
            0
          ]
        },
        "spay_email": {
          "$id": "#/properties/meta/properties/spay_email",
          "type": "string",
          "title": "The Spay_email Schema",
          "default": "",
          "examples": [
            ""
          ],
          "pattern": "^(.*)$"
        }
      }
    },
    "categories": {
      "$id": "#/properties/categories",
      "type": "array",
      "title": "The Categories Schema",
      "items": {
        "$id": "#/properties/categories/items",
        "type": "integer",
        "title": "The Items Schema",
        "default": 0,
        "examples": [
          12
        ]
      }
    },
    "tags": {
      "$id": "#/properties/tags",
      "type": "array",
      "title": "The Tags Schema",
      "items": {
        "$id": "#/properties/tags/items",
        "type": "integer",
        "title": "The Items Schema",
        "default": 0,
        "examples": [
          75,
          23,
          24,
          26
        ]
      }
    },
    "_links": {
      "$id": "#/properties/_links",
      "type": "object",
      "title": "The _links Schema",
      "required": [
        "self",
        "collection",
        "about",
        "author",
        "replies",
        "version-history",
        "predecessor-version",
        "up",
        "wp:featuredmedia",
        "wp:attachment",
        "wp:term",
        "curies"
      ],
      "properties": {
        "self": {
          "$id": "#/properties/_links/properties/self",
          "type": "array",
          "title": "The Self Schema",
          "items": {
            "$id": "#/properties/_links/properties/self/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "$id": "#/properties/_links/properties/self/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/pages/793"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "collection": {
          "$id": "#/properties/_links/properties/collection",
          "type": "array",
          "title": "The Collection Schema",
          "items": {
            "$id": "#/properties/_links/properties/collection/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "$id": "#/properties/_links/properties/collection/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/pages"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "about": {
          "$id": "#/properties/_links/properties/about",
          "type": "array",
          "title": "The About Schema",
          "items": {
            "$id": "#/properties/_links/properties/about/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "$id": "#/properties/_links/properties/about/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/types/page"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "author": {
          "$id": "#/properties/_links/properties/author",
          "type": "array",
          "title": "The Author Schema",
          "items": {
            "$id": "#/properties/_links/properties/author/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "embeddable",
              "href"
            ],
            "properties": {
              "embeddable": {
                "$id": "#/properties/_links/properties/author/items/properties/embeddable",
                "type": "boolean",
                "title": "The Embeddable Schema",
                "default": false,
                "examples": [
                  true
                ]
              },
              "href": {
                "$id": "#/properties/_links/properties/author/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://tesst.com/wp-json/wp/v2/users/1"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "replies": {
          "$id": "#/properties/_links/properties/replies",
          "type": "array",
          "title": "The Replies Schema",
          "items": {
            "$id": "#/properties/_links/properties/replies/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "embeddable",
              "href"
            ],
            "properties": {
              "embeddable": {
                "$id": "#/properties/_links/properties/replies/items/properties/embeddable",
                "type": "boolean",
                "title": "The Embeddable Schema",
                "default": false,
                "examples": [
                  true
                ]
              },
              "href": {
                "$id": "#/properties/_links/properties/replies/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/comments?post=793"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "version-history": {
          "$id": "#/properties/_links/properties/version-history",
          "type": "array",
          "title": "The Version-history Schema",
          "items": {
            "$id": "#/properties/_links/properties/version-history/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "count",
              "href"
            ],
            "properties": {
              "count": {
                "$id": "#/properties/_links/properties/version-history/items/properties/count",
                "type": "integer",
                "title": "The Count Schema",
                "default": 0,
                "examples": [
                  1
                ]
              },
              "href": {
                "$id": "#/properties/_links/properties/version-history/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/pages/793/revisions"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "predecessor-version": {
          "$id": "#/properties/_links/properties/predecessor-version",
          "type": "array",
          "title": "The Predecessor-version Schema",
          "items": {
            "$id": "#/properties/_links/properties/predecessor-version/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "id",
              "href"
            ],
            "properties": {
              "id": {
                "$id": "#/properties/_links/properties/predecessor-version/items/properties/id",
                "type": "integer",
                "title": "The Id Schema",
                "default": 0,
                "examples": [
                  799
                ]
              },
              "href": {
                "$id": "#/properties/_links/properties/predecessor-version/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/pages/793/revisions/799"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "up": {
          "$id": "#/properties/_links/properties/up",
          "type": "array",
          "title": "The Up Schema",
          "items": {
            "$id": "#/properties/_links/properties/up/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "embeddable",
              "href"
            ],
            "properties": {
              "embeddable": {
                "$id": "#/properties/_links/properties/up/items/properties/embeddable",
                "type": "boolean",
                "title": "The Embeddable Schema",
                "default": false,
                "examples": [
                  true
                ]
              },
              "href": {
                "$id": "#/properties/_links/properties/up/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/pages/525"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "wp:featuredmedia": {
          "$id": "#/properties/_links/properties/wp:featuredmedia",
          "type": "array",
          "title": "The Wp:featuredmedia Schema",
          "items": {
            "$id": "#/properties/_links/properties/wp:featuredmedia/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "embeddable",
              "href"
            ],
            "properties": {
              "embeddable": {
                "$id": "#/properties/_links/properties/wp:featuredmedia/items/properties/embeddable",
                "type": "boolean",
                "title": "The Embeddable Schema",
                "default": false,
                "examples": [
                  true
                ]
              },
              "href": {
                "$id": "#/properties/_links/properties/wp:featuredmedia/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/media/794"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "wp:attachment": {
          "$id": "#/properties/_links/properties/wp:attachment",
          "type": "array",
          "title": "The Wp:attachment Schema",
          "items": {
            "$id": "#/properties/_links/properties/wp:attachment/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "href"
            ],
            "properties": {
              "href": {
                "$id": "#/properties/_links/properties/wp:attachment/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/media?parent=793"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "wp:term": {
          "$id": "#/properties/_links/properties/wp:term",
          "type": "array",
          "title": "The Wp:term Schema",
          "items": {
            "$id": "#/properties/_links/properties/wp:term/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "taxonomy",
              "embeddable",
              "href"
            ],
            "properties": {
              "taxonomy": {
                "$id": "#/properties/_links/properties/wp:term/items/properties/taxonomy",
                "type": "string",
                "title": "The Taxonomy Schema",
                "default": "",
                "examples": [
                  "category"
                ],
                "pattern": "^(.*)$"
              },
              "embeddable": {
                "$id": "#/properties/_links/properties/wp:term/items/properties/embeddable",
                "type": "boolean",
                "title": "The Embeddable Schema",
                "default": false,
                "examples": [
                  true
                ]
              },
              "href": {
                "$id": "#/properties/_links/properties/wp:term/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://test.com/wp-json/wp/v2/categories?post=793"
                ],
                "pattern": "^(.*)$"
              }
            }
          }
        },
        "curies": {
          "$id": "#/properties/_links/properties/curies",
          "type": "array",
          "title": "The Curies Schema",
          "items": {
            "$id": "#/properties/_links/properties/curies/items",
            "type": "object",
            "title": "The Items Schema",
            "required": [
              "name",
              "href",
              "templated"
            ],
            "properties": {
              "name": {
                "$id": "#/properties/_links/properties/curies/items/properties/name",
                "type": "string",
                "title": "The Name Schema",
                "default": "",
                "examples": [
                  "wp"
                ],
                "pattern": "^(.*)$"
              },
              "href": {
                "$id": "#/properties/_links/properties/curies/items/properties/href",
                "type": "string",
                "title": "The Href Schema",
                "default": "",
                "examples": [
                  "https://api.w.org/{rel}"
                ],
                "pattern": "^(.*)$"
              },
              "templated": {
                "$id": "#/properties/_links/properties/curies/items/properties/templated",
                "type": "boolean",
                "title": "The Templated Schema",
                "default": false,
                "examples": [
                  true
                ]
              }
            }
          }
        }
      }
    }
  }
}

我确信这是有可能的,因为我一年前曾经这样做过,而且客户应用仍在运行。我只是不提醒我怎么可能。是否有一些可以添加到此请求中的属性,未记录。还是有一个插件将此属性添加到我的请求的有效负载中。

我正在使用WordPress版本5.2.3。

非常感谢

0 个答案:

没有答案