开发者 | meglio |
---|---|
更新时间 | 2015年8月14日 18:17 |
PHP版本: | 3.6.1 及以上 |
WordPress版本: | 4.2.3 |
版权: | GPLv2 |
版权网址: | 版权信息 |
http://mywordpress.com/my-api/name1
- change my-api and name1 in the plugin settingstwig-anything-api-endpoints.zip
to the /wp-content/plugins/
directoryJSON, XML, CSV (comma separated values), YAML and pretty much anything with just a bit of config. You have full control of what is output and which format.
Create as many endpoints as you need. There are no limits!
Yes, you can configure a minimum user role required for each endpoint separately. You will then pass username
and password
variables in your call to the API, which will be used to authenticate with your existing WordPress users.
Yes, every single API Endpoint has its own optional minimal role required to access the API.
If your API is public and meant to be accessed by anyone, then no. However, if you API needs authentication, then I recommend creating a separate WordPress user and using its username/password to access the API. A separate WP account for consuming your API would make it easier to switch it ON/OFF or change its permission level accordingly when required.
By default, you would access your API endpoint by a URL like this:
http://my-wordpress.com/api-endpoint/endpoint-name
... where api-endpoint
is the common root URL, and endpoint-name
is unique for every endpoint. Both of these pieces are configurable in the settings screen.
Yes, you can configure HTTP headers in the settings screen. To access it, click on the "Settings" menu and then on the "API Endpoints" sub-menu.
As any API, yours can return an error. For example, if someone tries to access a protected API endpoint without appropriate authentication. If this is the case, the Error Template from the settings screen will be used. There is a default error template in JSON format in place, but you can easily tune it to your own needs.
In the Settings screen, in front of every api endpoint there is an "Open" button. Clicking on it opens a new tab in your browser linking to the URL the API. You can also use special tools to test you API, for example Postman.
Twig Anything is a super-powerful plugin that allows to fetch any data from anywhere and display it in your WordPress site. It is universal and extensible, and already has a lot of things like intelligent error handling and local cache. It also understands Twig syntax, which allows for endless applications and various scenarios. "API Endpoints" greatly benefits from all of this! Last but not least, the developer behind both plugins is the same :)
Yes! You will need CSV Format add-on to read let it data from a CSV file.
Yes, just configure your Twig Template to fetch data from a URL and then output it either entirely or partially in your template.