Giving Your Blog a Brain
Turn your Apps Script into a Web App that Blogger can talk to.
Your Blogger site is beautiful, but it's just a "Display." To make it "Smart," we need to link it to your Apps Script workshop. Today, we'll turn your script into a Web App URL.
- What a Web App is.
- How to use the
doGet()function. - How to "Deploy" your script to get a public URL.
This is for the "Web Developer" student. If you want to put a "Contact Me" form or a "Live Score" box on your Blogger page, this module is the secret key that opens that door.
Think of a Pizza Delivery App.
Your Phone (Blogger) is where you see the menu and click "Order." But the kitchen (Apps Script) is where the pizza is actually made.
The Web App URL is the delivery boy who carries the order from your phone to the kitchen and brings the pizza back!
doGet Function
In Apps Script, doGet is a special name. It tells Google: "Whenever someone visits my script's URL, do this!"
It’s like a Welcome Mat. Every time a visitor (Blogger) steps on the mat, the script wakes up and says "How can I help you?"
doGet function in your script.To talk back to a website, we have to return a special type of text called TextOutput. It’s like the "Receipt" we give back to Blogger.
// 1. Create the message
const message = "Hello! Your Blogger site is now connected.";
// 2. Send it back in a way websites understand
return ContentService.createTextOutput(message);
}
Copy this into your Apps Script editor, then click the blue Deploy button at the top right.
Once you deploy, you'll get a URL that looks like this:
https://script.google.com/macros/s/.../exec
If you paste that URL into your browser, you will see a white screen that says: Blogger Bridge: ONLINE. This means any website in the world can now hear your script!
Click to fix deployment issues
1. Access Denied: When deploying, you MUST set "Who has access" to Anyone. If you set it to "Only me," Blogger won't be allowed to talk to the script.
2. New Deployment: Every time you change your code, you must click Deploy > Manage Deployments > Edit and choose "New Version." Otherwise, the URL will still use your old, broken code!
3. Spelling: It must be exactly doGet (lowercase 'd', capital 'G'). If you type doget, it won't work.
Change the message in the code to "System: Operational - [Your Name]". Re-deploy the script and refresh the URL in your browser. Can you see your name on the screen?
Websites like Wikipedia use this! They have a "Base" (the text) and a "Brain" (the database). Every time you search for a word, the "Base" talks to the "Brain" using a URL, just like you are doing now!
You’ve just built a public API! That sounds fancy, but it just means you've created a way for the whole internet to talk to your code. You are ready to build real-world projects on your blog.
Status: Bridge Builder 🌉 | Level: Web Developer 🌐