In this blog article, I will discuss about how we can easily integrate a WordPress blog with your SharePoint site with the help of SharePoint 2013 designer Work Flow.
Introduction
Using SharePoint 2013 REST API and building SPD based simple Workflow, we will fetch most recent 2 or more post from the blog site and add those in a SharePoint list.
If you are more interested about the advantages and disadvantages of the REST API, and for a comparison with other API’s.
REST API Reference
Firstly, we will try to get the REST API provided by WordPress. Let’s go to WordPress developer’s resources site.
Here, you can get the list of REST API, from which you can choose as per your requirement.
In order to retrieve most recent 2 blogs we will be specifying the number=2 in the parameter such as below:
https://public-api.wordpress.com/rest/v1/sites/yourwordpressblog.com/posts/?number=2
Building SP2013 SPD Workflow
Open the SharePoint Designer and click on site work flow.
As you can see in the image, we will build a site workflow named “Get WordPress Recent Blogs”, which will read the information from WordPress Blog, create list items in a SharePoint list for further use.
Once the site workflow is created, you simply add stages, loops and name them properly, and then link them actions.
Name Stage 1 “Get Myblog Recent Items” and then add five actions and one Loop block, as shown in Figure 1.
Figure 1. Workflow Stage 1
- Action 1 is not really required, but it will add one item to the history list, which can be used for debugging.
- Action 2 is added to Call HTTP Web Service action. The HTTP URL is set to https://public-api.wordpress.com/rest/v1/sites/yourwordpressblog.com/posts/?number=2 and the HTTP method is set to “GET”.
- Action 3 is again logging to history, the response should be “OK”. This means the WF is calling API perfectly.
- Now we are creating a variable “itemcount “as Integer and setting the value to 2, since we require only 2 blogs.
- Last action is to create another variable “Index” and set the value to 0.
In the “Call HTTP Web Service” action statement we do not set RequestContent or RequestHeaders parameter because we do not need to. We are only interested in the output of that web service. By simply setting the response parameter to a variable ResponseContent, the output of this web service call will get stored in the variable ResponseContent, which is a dictionary type variable.
The output of the web service looks like the following:
{“found”:5,”posts”:[{“ID”:124,”author”:{“ID”:7899331,”email”:false,”name” ……………..
To handle each blog item we could use the “responsecontent” variable so that we can put our action statement like “Get ([%Variable: Index%])/Title from Variable: responsecontent” to get Post’s property.
From the web service output we can see the ID, title. These are within “posts{“. Just to make things simple and to show a clear structure of post inside web service output, the full path to access post’s properties, the statement like “Get posts[%Variable: Index%])/ID from Variable: ResponseContent“ will retrieve ID property of an item.
These are the workflow variable details:
Figure 2 shows all the different action items.
- Firstly, pick the ID
- Next, delete the same ID if the item exits in the SP list
- Next four action is updating the variables with posts’ value
- Last item in the loop is to add an item in the SharePoint List
Now increase the counter by 1 and the same actions are for the 2nd Item.
This is it! You are now you are ready to publish and start this workflow.
If you want to run the workflow daily, then add another action item after the loop end such as below:
Now your SharePoint List will have the blog content . That’s it 🙂
Best SharePoint Hosting Recommendation
ASPHostPortal.com
ASPHostPortal.com’s Best ASP.NET hosting platform on Windows 2012 and Windows 2008 is compatible with SharePoint 2013 hosting. Needless to say, you’ll be able to really feel very comfy with their hosting service. Their best and inexpensive SharePoint 2013 hosting package is starting from $9.99/mo only. And with their promo code, you will get free domain as well. Not just that, in addition they supply 30 days cash back guarantee. Their servers are 99.99% uptime, it’s important believe which you require for your SharePoint 2013 site, so your website is by no means down.
HostForLIFE.eu
HostForLIFE.eu offer the Best, Cheap and Recommended SharePoint 2013 hosting start from €9.99/month. They can load your site against anticipated traffic and recommend the best option for you. HostForLIFE.eu is Microsoft No #1 Recommended Windows and ASP.NET Hosting in European Continent. Their service is ranked the highest top #1 spot in several European countries, such as: Germany, Italy, Netherlands, France, Belgium, United Kingdom, Sweden, Finland, Switzerland and many top European countries.
DiscountService.com.au
Get high functionality, best uptime along with the most dependable SharePoint 2013 Hosting site with them. SharePoint 2013 hosting from DiscountService.com.au provides a protected, trustworthy and performance-driven foundation for your website and apps. If you’re searching for the correct Windows ASP.NET hosting that support SharePoint 2013 hosting provider, they are the correct selection for you. They have proactive monitoring down to seconds with reactive options in spot to ensure the stability in the services they offer. All hosting servers are monitored 24/7/365. They use enterprise software to monitor their whole network infrastructure. Their very best and inexpensive SharePoint 2013 hosting price begins from $10.00 monthly.