I am developing an android app. I dont know anything about wordpress database or how to get data from the website. I googled for how to get data from the wordpress database I have got to know I could get json response from JSON API plugin of the wordpress. but It's hard for me to understand.
I am using food bakery theme for wordpress.
I just want to know how do I get required json response from this website. And where the data of products in that website is located in database.
for example : product,categories etc. etc
My expected response is something like this
{"Category":[{"ProductSubGroupCategoryCode":"PSG03","ProductGroupCategoryCode":"PG01","Description":"WRAPS"
,"CHello SirreatedBy":"101","CreatedDate":"\/Date(1486116932060)\/","ModifiedBy":null,"ModifiedDate":null}]},
{"SubCategory":[{"ProductID":"01","Description":"VEG BURGER","ReferanceID":"VEG BURGER","UOM":"EA","AlterUOM":"EA",
"ProductGroupCategoryCode":"PG01","ProductSubGroupCategoryCode":"PSG01","TaxCategoryCode":"","TaxCode":"VAT5","BuyPrice":100,
"AttributeCode":"PA01","BasicPrice":190.48,"TaxRate":5.00,"SalesPrice":200.00,"ProductImage":null,"CurrentStock":10,
"PlantCode":"PC01","StoreLocationCode":"S01","DisplayOnPOS":true,"POSDisplayOrder":0,"CreatedBy":"101",
"CreatedDate":"\/Date(1486446663333)\/","ModifiedBy":"101","ModifiedDate":"\/Date(1486447253063)\/"}
Edit:
I tried with WP REST API i have come upto, when i use this link it gives me response with id 1 http://localhost/mysite/wp-json/wp/v2/posts/1.
when when I have tried with other post IDs it gives me blank response.
FYI I got post ID for that certain post from wordpress_posts table of wordpress database
if you want to get post:
https://example.com/wp-json/wp/v2/posts
if you want to get a particular post
https://example.com/wp-json/wp/v2/posts/1852
whereas 1852 is the id of the post
For getting JSON response from word press site you need to install certain open source plugin on word press site
here is an WP API link
Click here
As per documentation You can also create custom API
You can access your posts json on wordpress with
http://oursite.com/wp-json/wp/v2/posts
Related
This is my first time working with Wordpress APIs, and i'm not a PHP developer. Essentially our client just wanted us to display WordPress articles in our react-native app with simple data like the:
date
title
content
thumbnail
etc..
...anything you'd find in the default response, and this was easy. We simply used the default endpoints like this one: https://demo.com/wp-json/wp/v2/posts?categories=1015
Anyways... Our client now wants to display the "view count" of each article. However, i can't find that data in the default response:
Is there a way to get this view count data, and have it return in the API response, without having to customize every single endpoint?
Thanks
I'm trying to automate posting entries to a blog every time a specific action happens on my website.
I've been looking at the Wordpress documentation but I've only seen that I can put as the structure of the post. I would be interested in creating entries with text and images. Would it be possible to do this?
The text and images would be taken from the web page.
I'm using php with Laravel and the blog is in wordpress.
You can send a POST request to the "post" endpoint to POST a new post (no pun intended) (docs).
Although the content parameter is said to be an object in the docs, you can pass a HTML string to it like <h1>Some cool event happened</h1><p>See this picture</p><img src="https://some-path-to-picture.com/picture.png">
It seems you can even add images along with your content to be hosted on your wordpress site (see this Github question)
I'm using wordpress and developed an angular code to open a button in my DOM The calculated fields are correctly working, but I need to use a angular created code to display a button in according to an parameter (called campanha) value.
Let me try explain th history:
I'm working with Marketing in Google Adwords campaigns, and we created 3 campaigns, (one for Brazil, other for US and other for UK, i.e.), and the values of each campaign are sent to me through the Google search page.
Below I have an example from what I'm talking:
<http://www.redecidada.org.br/calculo-cota-aprendizes> (working)
<http://www.redecidada.org.br/calculo-cota-aprendizes?campanha=mg> (404)
<http://www.redecidada.org.br/calculo-cota-aprendizes/?campanha=mg> (404)
It seems that the problem is on your wordpress page/configuration.
If you try: http://www.redecidada.org.br/calculo-cota-aprendizes/?nome-campanha=mg.
There's no problem if you change "campanha" text... The error is in your code/page. Need more info.
I am using onesignal notification plugin wordpress implemented in my android app every thing works well The problem is that i want when user tap on the notification i want to get the wordpress site post 's full content data (post title + post description) ...i know thas json return push content "additional data" but it content only post title and url post (not content the post full data like description and the writter) !
those data i wil explore it to manipulate the post detail 's activity (do not inclure any webview ! )
i asked the onesignal team about it and they purposed me to modify the plugin php code directly using onesignal_send_notification_filter($fields, $new_status, $old_status, $post)
i need a help to solve it
thanks !
onesignal_send_notification_filter() is a WordPress filter hook that allows extending our plugin's behavior without modifying our plugin's code. See this section of OneSignal's documentation for more information, including beginning sample code.
Inside the callback, you have access to the $post object, which comes with these fields, including the post_content field.
so I am trying to use WP-API plugin:
i figured out how to get all posts for custom post type:
http://domain/wp-json/posts?type[]=customType
and i figured out how to get attachments:
http://domain/wp-json/media/
Now the problem is how to get images attached to single post. if I look at the soruce it seems to suggest a path like:
http://domain/wp-json/media/<postId>/
but I get an error:
[{"code":"json_post_invalid_type","message":"Invalid post type"}]
any Idea how to get this to work?
You can use the "parent" id argument, e.g:
$ curl http://demo.wp-api.org/wp-json/wp/v2/media?parent=<id>
where is the post's ID. What we do is ignore all versions of images except the original, which is found by looking for the GUID > rendered value, e.g:
guid: {
rendered: "http://demo.wp-api.org/wp-content/uploads/image-belonging-to-this-post.png"
}
As of this moment this functionality does not seem to be supported probably will be when the plugin goes into core but for now it is as is.
I ended up making my own json API to serve my needs by making the page templates recive emit JSON data.
Just an update to this old post. WP-API now supports getting media related to a particular post.
http://v2.wp-api.org/reference/media/
Code:
$ curl http://demo.wp-api.org/wp-json/wp/v2/media/<id>