I'm currently working on application where I want to use data from my blog which is hosted on digital ocean. I have installed wordpress for the blog on the server with domain name abc.com. I have to call wordpress rest api to get data without authentication if possible or using application client secret key. How we can do that?.
While calling like this "https://public-api.wordpress.com/rest/v1.1/sites/abc.com/posts/?pretty=true"
this return
{
"error": "unknown_blog",
"message": "Unknown blog"
}
do you mean
abc.com/wp-json/wp/v2/posts
url like this will get the all posts title content, and if you want to get single post, you can do
abc.com/wp-json/wp/v2/posts/1
1 is post_id , you can replace with other post id
Below function is useful for register endpoint for creating API from function.php file. Refer below link for further deployment.
register_rest_route
https://developer.wordpress.org/reference/functions/register_rest_route/
Below link is very helpful for create API in WP environment.
http://v2.wp-api.org/
You can get overview from below word press popular plugin as well, but in latest word press there is no need to use this plugin as default word press provide almost all functionalities.
WP REST API (WP API)
Related
I tried to use one plugin called "WP Data Sync". I am also going through its documentation/ support for the same. I am also having wpbakery page builder in my website. So is there any way that we sync with that also?
Note - We have to sync data in the form of images, image gallery, events listing, and the blog posts.
Did you check out WP Data Syncs website at https://wpdatasync.com/ and create an account to check out an API key?
I'm not sure about all APIs, but the ones I've used in the past would require me to register with the API's website, get issued an API key and maybe even designate the key to a specific website (your WordPress site in this case) for security reasons. After that, you would then go to your WP site and setup the API there via WP DataSyncs plugin.
I hope I understood your question and that this helps.
I have a wordpress website who publish articles, i want to automacaly send a selection of articles to users in their facebook messenger
I saw a website that do that, and I want to do same
Thank you
Maybe there is a Wordpress Plugin for that, but I would do it like so:
Creating a cronjob and executing a php file once a day. (How this works in WP: https://www.a2hosting.com/kb/installable-applications/optimization-and-configuration/wordpress2/configuring-a-cron-job-for-wordpress)
This file is getting all the new posts (or maybe posts with a specific WP Tag or whatever you want to send to your users) from the WP API.
Then, in this file, you connect to the Facebook Send API https://developers.facebook.com/docs/messenger-platform/reference/send-api/ and send this posts to your users. Read the API docs for how that actually works
I have a Wordpress site and a Laravel site and I want to display recent wordpress posts in the footer of Laravel site. How can I do this without having my wordpress database information in my config/database.php file and using it in the models? Can I get them using RSS?
Recent WordPress was released with a huge thing called REST API – earlier it was possible only with external plugins. So now we can query WordPress database from external projects. Including Laravel.
set up a local WordPress website, and after installation you got that usual dashboard.
we can already make API calls after installation. No need to configure anything, we just launch the URL in the browser:
we’ve received a JSON with a list of posts – by default, WordPress creates one dummy post.
Basically, URL structure for the API calls is simple:
/wp-json/wp/v2/[endpoint]?[parameters]
Yes, you’ve read it right, we can get posts, categories, tags and other things that are publicly available, so we don’t need any authentication here.
And we also can filter the data with GET parameters, like this:
/wp-json/wp/v2/posts?per_page=2&orderby=title
For more details open link:- Using WordPress REST API in Laravel
You can get the posts by calling an API endpoint:
yoursiteurl/wp-json/wp/v2/posts
It will return all the posts in a json format. You can also see the reference from here.
I have created a blog on Wordpress.com, I can access the api and returned posts from the homepage with this:
https://public-api.wordpress.com/rest/v1/sites/{siteID}/
So my blog is access via URL at something like www.blog.home.blog
However I have a second page that is at www.blog.home.blog/secondPage
The API doesn't return Posts from this URL. Trying to understand what I need to change to the API URL to return posts from this second page?
You need to provide the ID of this page/post you are trying to access. It will be something like https://public-api.wordpress.com/rest/v1.1/sites/$site/posts/$post_ID And to get all the posts you can use https://public-api.wordpress.com/rest/v1.1/sites/$site/posts/
More info is available here at the official wordpress.com documentation for developers.
We're building multiple single page apps that all consume the same service based API. One of our requirements is to offer a simple CMS that allows an admin to create marketing pages.
I was able to set up a wordpress instance using the multisite plugin and put it behind our own API. This allows us to use wordpress as a CMS service. We can create pages in the wordpress admin area and then pull the content in using the wordpress rest api plugin.
One of the problems I'm having is to migrate our key, value translation string files into wordpress. We'd like to store them in the database and use wordpress as a place to edit them and then query for them using the rest api plugin. Our translation files are json format and look like this:
{
"LOGIN_LABEL": "Sign In",
"LOGOUT_LABEL": "Sign Out",
"SIGN_UP_LABEL": "Register"
}
Looking for any solutions that would help us use wordpress as a place to store key value pairs, edit them, and do GET requests to pull them in.