I was trying to write some small cli to push my posts to Blogger from the commandline. There are some tools out there, including googlecl and blogger-cli but no nodejs tool as far as I know. So, I registered to use Blogger API. Unfortunately, you'll have to wait 5 days just to get approval and instruction from Google, and that process is handled by only one man, Brett. So, while waiting for the API, here's my work around.
- From Google's code console, get your API key and stored it in
~/.bash_profile
. Let's call itGOOGLE_API_KEY
- Head over to Blogger API sandbox and try some service that require authorization, e.g. inserting post. Note that you won't need this if you just want to get posts or comments or some actions that don't require authorization.
- Execute the service with the browser's console open. Watch in the Network tab for the post query
- In the query URL, look for key Bearer, then copy its value and store in
~/.bash_profile
. Let's call itBLOGGER_TOKEN
- Also, get your blog's ID and save it in
~/.bash_profile
as well. Let's call itBLOG_ID
Following is the simplified code snippet allows you to push your content to Blogger.
let nconf = require('nconf'),
request = require('request');
nconf.argv()
.env();
let apiKey = nconf.get('GOOGLE_API_KEY'),
bToken = nconf.get('BLOGGER_TOKEN'),
bID = nconf.get('BLOG_ID'),
bURI = 'https://www.googleapis.com/blogger/v3/blogs/' + bID;
request.post(
{
url: bURI + '/posts?' +
'fetchBody=true' +
'&isDraft=true' +
'&key=' + apiKey,
form: {
labels: ['nodejs', 'sandbox'],
title: 'Test CLI',
content: 'This post was pushed from command line.'
},
auth: { bearer: bToken }
},
function(error, response) {
if (!error) {
console.log('Mission completed!', response.statusCode);
}
else {
throw error;
}
}
);
NOTE: the main problem with this approach is the bearer token expires after certain period of time
looking for remote developer jobs? Take a look at http://webwork.io
ReplyDeleteyou have started great blog for Nodejs. its very useful for new.
ReplyDeleteFree eMenu Ordering System
online booking system software
Digital Menu for restaurants
Excellent post--I'm glad I found it.Thanks for sharing...
ReplyDeletenode.js development services
Thank you.Well it was nice post and very helpful information on AngularJS Online Training
ReplyDeleteCheck out a handy list of famous companies that use node.js in production .
ReplyDeletekhong biet lay BLOGGER_TOKEN nhu the nao admin oi?
ReplyDeleteEnjoyed reading the article above, really explains everything in detail, the article is very interesting and effective. Thank you and good luck for the upcoming articles learn Node JS training
ReplyDeleteHey!!Nice post i got to learn so many things.
ReplyDeletePlease Check out this one Node JS
nice post!!!!
ReplyDeleteLearn more about this check here Nodejs
Rails is basically a web application framework, which is consist of everything needs to create database baked web application. It helps the developers to create websites and applications by providing structures for all codes written by them. Moreover, common repetitive tasks are simplified with the help of this technology.
ReplyDeleteruby on rails software house
Popular rails gems and APIs
Websites made with ruby
Best ruby gems 2019
React native and React Js
Node Js and React Js
Appsinvo is the Top Mobile App Development Company to deliver end-to-end services and solutions to the clients.
ReplyDeleteTop Mobile App Development Companies in Australia
Top Mobile App Development Companies in Sydney
Top Mobile App Development Companies in france
One software for all your problems- Nodejs web development framework. We believe in delivering the best and that’s why Inwizards nodejs development company is in the software industry for more than a decade.
ReplyDeleteWhy hire node js developers from Inwizards?
Highly experienced Nodejs Developers
Mastery of latest technologies
Transparent workflow
Affordable prices
500+ successful projects
24*7 Support
Custom Application Development
Rich client history
If you want to achieve success for your business, Inwizards LLC provides the best node js development services.
Feel free to get in touch with us for further discussions and pricing details. Here are our contact details:
Website Address: https://inwizards.com/nodejs-development-company.php
Email: info@inwizards.com
Call: USA - +1- (979)-599-0896 | IN- +91-9667584436
We’ll take care of your IT goals so let’s build something great together. Inwizards NodeJS development company is your compatible partner. Build nodejs web development applications with ease at Inwizards!
ReplyDeleteWhy hire NodeJS developers?
Highly experienced Nodejs Developers
Mastery of latest technologies
Transparent workflow
Affordable prices
500+ successful projects
24*7 Support
Custom Application Development
Rich client history
If you want to achieve success for your business, Inwizards LLC provides the best NodeJS development services.
Feel free to get in touch with us for further discussions and pricing details. Here are our contact details:
Website Address: https://www.inwizards.com/nodejs-development-company.php
Email: info@inwizards.com
Call: USA - +1-(979)-599-0896 | IN- +91-9667584436
Thanks for sharing nice information. Find the best nodejs development services for your business.
ReplyDeleteGood Informative Blogs! For Projects like Ecommerce, Delivery Apps Node JS is Prefered! If you have any questions on Node JS Development you can talk to Echoinnovate IT!
ReplyDeleteWe appreciate your blog article very much. There are many of alternative options after visiting your post. I knew exactly what I was searching for. I value your posts and I hope you keep them up. Fantastic work.
ReplyDeleteBest Software Development Company In Mohali
Mobile App Development Company