Onesignal wordpress notification get post data to android app - php

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.

Related

How to add a post's view count into the WordPress API response

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

Posting with Wordpress API REST

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)

how to get json response from wordpress website

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

wordpress REST API - How to fetch style information?

I want to use the WordPress JSON api to fetch content for a mobile app. I can iterate over the posts I receive - and I notice there is a "Rendered" field in the posts. I want to display that to the mobile user. Generally in a scrolling list view. However that rendered content is missing all styling CSS information. I'd like to embed that JSON API "rendered" content in web-views without fetching each of the whole posts like www.example.com/customtype/slug1 in WebView1 then the same for slug2 in WebView2 etc. I mean - I already fetched the content part - just missing the styles. Mobile data is precious :)
Is there a way to fetch the CSS information for a post in the active theme via the REST API? I tried caching style info in a global var as discussed in this SO answer (which I verified in debug). Then adding a custom REST endpoint to fetch the stuff I stored in that global variable. This almost works. The endpoint works. The data is cached after I display any post. However the global var in the child theme required to make this work appears to not be in the same scope as the plugin where I'm putting my rest to mobile stuff (that same global is always null/empty in the plugin).
My thoughts are now to make a custom post display in my child theme that just emits only the wp_head() stuff and I then fetch&cache that in the app - but that seems awkward. But I'm new to WP and PHP so - here we are. Thanks for any help!

Is it possible to preview a wordpress post remotely without publishing it?

I am struggling with remote post preview using wordpress api.
Currently I am publishing new post, capturing html and deleting post.
This works, but I am looking for better solution.
I have an app which is publishing posts remotely to Wordpress. I need to add functionality of post preview on somebody's blog which will be viewed in my app. I need to get full html of wordpress site with post content which is held in my app. I am publishing post using this: http://developer.wordpress.com/docs/api/1.1/post/sites/%24site/post‌​s/… capturing html and deleting this post. This solution has lot of disadvantages, for example when wordpress user inform his readers about new post via email, readers will get a notification about new post that doesn't exists any more.

Categories