Do it like Zapier.com : RSS to Wordpress.com

I want to do IFTTT from RSS to Wordpress.com to feed my blog post, since I'm a lazy blogger :). ,
I have a URL feed, and for each news item, it will be my post.
Of course I have to insert the real URL source, so my reader can click the complete URL page.
But IFTTT.com is always have error, and when it reach 5 error, it would stop the tasks.

So I'm looking for IFTTT.com alternatives. And Google said it's Zapier.com.
After register I start create new Zap. Basically in a Zap you can create a workflow. The free plan is 2 steps workflow. Each Zap will continue every x minutes do the Task, (step 1) move RSS items from one URL feed to (step 2) send new post on Wordpress.com. It will give you 14 days trial.
And after the trial it will stop continue my Zap because I have too many Tasks for the free plan :).
I don't have any interest to continue my plan because I'm a dotnetarian. I think I can find a way to code this. Simply writing a console apps.

Start with searching nuget library to read RSS. I'm using https://www.nuget.org/packages/CodeHollow.FeedReader/.
Then find a way to send new post to Wordpress.com.
After read their developer page, I can use their API. But I need to get the API token code first from OAuth2. How?.

After Googling for a (very long) while, I give a try to a sample from github : https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers. This sample have a code for OAuth2 Client for Wordpress.
Debugging into OAuth2 workflow, until I reach this line 37 on WordPressAuthenticationHadlers.cs, tokens.AccessToken. Yes I have the token, now it's time to use this token to send new post.


Before I'm trying to test the token, I remember Postman. Because the OAuth2 workflow is actually pretty simple, I think Postman can handle it easily. And yes there's one tutorial, Google direct me to https://community.blackboard.com/thread/4359-using-postman-to-try-out-the-rest-apis. Try a little bit and yes it works. The output is the same token code I get from debugging asp.net security oauth providers sample.

Now this is the real code, feel free to comments.

Slug urlfriendly code from https://www.johanbostrom.se/blog/how-to-create-a-url-and-seo-friendly-string-in-csharp-text-to-slug-generator.

Function to loop dictionary feeds. Define your url in dictionary feeds, and it will loop forever.

Read RSS and loop feed url items to send to wordpress.com
Send new post to wordpress.com using HttpClient
Rest api from wordpress.com is very fast to return if there are slug title exist

Comments