Fetching content from webhook wordpress? - php

I am developing a web app which, among other things, enables users to write a small text, have it saved, and automatically posted to their wordpress blog.
I am wondering about Wordpress as my platform, which has already some features that I need.
Wordpress has webhooks that sent notifications to other websites. I would like to know if it is possible to send content [short text] with the notifications and display it as a post in the final wordpress blog.
Other suggestions are also welcome.
Thank you very much.

I think you are asking if you can use Wordpress as the base of your new web app, and use the webhook functionality in Wordpress to send data to other Wordpress blogs.
If this is correct, you can use webhooks to send data from Wordpress to somewhere else. Wordpress allows you to send webhooks when a new post is created, when a new comment is made or when a new page is created.
Webhooks are outbound-only and they are one-sided, that is to say that you can get Wordpress to send a webhook with the content you want, but you have to have something on the other side to catch the incoming data. That thing must understand what Wordpress webhook data looks like and how to call the Wordpress API on the receiving side.
Wordpress does not understand how to receive webhooks, even if they are sent by another Wordpress site.
You could accomplish what you want by writing a Wordpress plugin that could call the other Wordpress via api. The call you would want is here:
Wordpress API call to create a post
Unfortunately, there are very few options in terms of handling incoming webhooks apart from writing custom code to catch the webhook and do something with it. The company I work for created something to do things like this, but it's still in private beta. (see my profile if you are interested)

Related

How to build a basic web app on WordPress site using AWS API Gateway

I want to build a simple Software-as-a-service web application that performs web scraping - the result per execution will be a table of results with several rows and columns. For the front-end, I wanted to build the website using WordPress since I am familiar with making basic websites there and like the plugins available. For the backend I plan on using AWS Lambda to perform the task serverless-ly. The user will log in to the site, then when they want to use the service will enter some keywords via a form, and that will send HTTP request to AWS API Gateway, which is connected to my Lambda function. Currently, the AWS Lambda function writes results into AWS DynamoDB as it goes - perhaps I need to write a second HTTP request method to query the results, or return the results in the same method that scrapes them instead.
Even after hours of googling, there are several areas in which I am unsure how to proceed, or if I have chosen the right path (I have no prior experience in this area.) Two of the biggest puzzles I have currently though are:
How can I use WordPress to send data to AWS API Gateway? Do I need to write some PHP code and if so what does it look like and where should I put it?
How can I present the results on WordPress site for the user? Should I keep the results saved on DynamoDB and query them when I want to present them, or should I store the results on the WordPress database? Ideally they would see a big table and have options to export to CSV, for example.
Thanks for your help and patience.
Cheers,
jack
There are a couple of possible ways this can be accomplished. One way is to just use webhooks. Most form plugins come with the option to use webhooks and doing it this way is pretty straightforward. Here is an article from WPForms on how to configure it WPForms and Webhooks. Below is an example of how I have used it. The example shows a form that sends data to AWS API Gateway which triggers AWS StepFunctions and also puts the customer information in DynamoDB
WPForms Webhook to AWS API Gateway

Trigger laravel event from wordpress

I'm currently working on a laravel app.
The same app is already running on wordpress and through the laravel application we are going to add some additional features in original application.
The laravel will run on the subdomain.
Here is the thing:
On wordpress website, we are publishing different public articles but on the publishing of these articles we need to send an email to either "all employees" of company or "all managers" of the company.
The company employees detail is stored and available in laravel.
I was hoping that there'll be a way through which on article publishing, I will give two options to the user on wordpress: "Send email to employees"/"send email to managers" and on selection of any of the option, email send event will be triggered from my laravel website.
I've almost no experience of wordpress. I was trying to google it but couldn't find any helpful links.
WordPress works quite different then laravel, and is working with many hooks..
You could monitor post status changes with: https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post
You have to implement the email sending your self inside this hook,
And also trigger a webhook against your laravel endpoint.
The publish button in wordpress does not allow you to select who to send an email.., But this can be build with custom fields / meta data on your post.
Quite depends on how you would like to implement that.
Unfortunaly WordPress does not work with composer by default therefore you don't have an easy way to get packages like Guzzle to send your request to your larvel endpoint.
WordPress has some build in methods to do REST calls, see:
https://developer.wordpress.org/reference/functions/wp_remote_request/

how to integrate facebook "App-to-User Notifications" into wordpress post comments

Facebook re activated the App-to-User Notifications again.
i am trying to find a way to make my wordpress website send a notification to my user when someone writes a comment to his post on my website.
my users are registered using their Facebook accounts.
Facebook just mentioned that Apps can generate notifications by issuing a HTTP POST request to the /user_id/notifications using
POST /{recipient_userid}/notifications?access_token=... &template=...&href=...
How to integrate this API call into wordpress?
Thanks
Well, your question is too wide because it seems like you are asking the whole guide on how to implement this API call in Wordpress.
So let me just give you the direction:
Get the Facebook PHP SDK from git here: Facebook SDK for PHP (v5)
Implement Wordpress HOOK either in your theme or in the plugin, so that you can handle things when comment is posted. Wordpress Comment Post Hook Document
So in Wordpress side, you will need to create a function which takes the facebook user token who made a post, make an API call, and then link this function to comment_post hook.
Hope this will give you an idea.

How to post a comment in a wordpress website, using the wordpress REST API, in android

I have been developing an android application to view and comment on posts of my website. Getting posts is easy using GET requests. I cannot post comments though, as it is a POST request which requires authentication. I want Google sign so that users can comment on a post on their phones. How do I use the wordpress REST api to do so. Documentation for the REST API and commenting are mentioned here.
https://developer.wordpress.com/docs/api/1.1/post/sites/%24site/posts/%24post_ID/replies/new/

Create a broadcast service for my website in PHP

I have created a dashboard using PHP and Wordpress, the problem i'm facing now is that I need to create an alert or a message when ever a new data has arrived in any users dashboard. So, I need to send the users that are currently online in the dashboard, a notification that a new data has arrived for them.
Whenever a data has been added by me for a particular user, an automatic notification should be shown on the that users screen if he is online. I have created the dashboard, but I don't know how to implement this notification.
In short, I want to create something like a push notification inside my website.
Use Atmosphere framework for braodcasting any messages. This essentially uses Websockets in the implementation. But its very easy to do.

Categories