{"id":80347,"date":"2026-11-27T20:35:21","date_gmt":"2026-11-27T20:35:21","guid":{"rendered":"https:\/\/www.devopsschool.com\/blog\/?p=80347"},"modified":"2026-11-27T20:35:23","modified_gmt":"2026-11-27T20:35:23","slug":"google-blogger-automation-complete-guide-to-blogger-api-claude-code-codex-and-playwright","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/google-blogger-automation-complete-guide-to-blogger-api-claude-code-codex-and-playwright\/","title":{"rendered":"Google Blogger Automation: Complete Guide to Blogger API, Claude Code, Codex and Playwright"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Practical tutorial | API publishing, scheduled workflows, multi-blog management and XML theme deployment | November 2026\n<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"630\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/google-blogger-automation-with-ai-coding-agents-r.jpeg\" alt=\"Google Blogger automation with AI coding agents, REST API and browser-based theme management\" class=\"wp-image-80348\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/google-blogger-automation-with-ai-coding-agents-r.jpeg 1200w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/google-blogger-automation-with-ai-coding-agents-r-300x158.jpeg 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/google-blogger-automation-with-ai-coding-agents-r-1024x538.jpeg 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/google-blogger-automation-with-ai-coding-agents-r-768x403.jpeg 768w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/google-blogger-automation-with-ai-coding-agents-r-820x430.jpeg 820w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"caption wp-block-paragraph\">\n  Featured image (1200 \u00d7 630 px): Blogger automation with API and browser workflows.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Google Blogger is a hosted publishing platform, but you do not need to open its dashboard every time you publish an article. Its REST API allows authorized applications to manage content. AI coding agents can build and operate those applications, while browser automation can assist with tasks that the public API does not expose.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  The central lesson is to separate content management from site administration. Use the official API for supported operations. For XML themes, layout and settings, use the dashboard or carefully supervised Playwright automation. Do not rely on undocumented private endpoints.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">What you will learn<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Set up OAuth, discover blog IDs, create drafts, edit and schedule posts, manage pages and comments, use AI coding agents and MCP, upload XML themes with backups, and operate a reliable multi-blog publishing system.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">1. What Blogger API v3 can and cannot do<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Blogger API v3 is a REST interface for interacting with content and selected blog metadata. It is not a full hosting or site-administration API. The following matrix reflects the documented resource surface; browser actions depend on the dashboard, account permissions and interface changes.\n<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><p><strong>Capability<\/strong>\n<\/p><\/th><th><p><strong>Official API<\/strong>\n<\/p><\/th><th><p><strong>Dashboard \/ browser<\/strong>\n<\/p><\/th><\/tr><\/thead><tbody><tr><td><p>\n  Discover blogs and read metadata\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><\/tr><tr><td><p>\n  Create, edit, delete posts\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><\/tr><tr><td><p>\n  Draft, publish, schedule, revert\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><\/tr><tr><td><p>\n  HTML, labels, linked images\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><\/tr><tr><td><p>\n  Create, edit, delete static pages\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><\/tr><tr><td><p>\n  Read \/ moderate comments\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><\/tr><tr><td><p>\n  Create comments \/ replies\n<\/p><\/td><td><p>\n  No public method\n<\/p><\/td><td><p>\n  Yes, where enabled\n<\/p><\/td><\/tr><tr><td><p>\n  Read user and pageview data\n<\/p><\/td><td><p>\n  Yes, limited\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><\/tr><tr><td><p>\n  Create \/ delete blogs\n<\/p><\/td><td><p>\n  No\n<\/p><\/td><td><p>\n  Yes, subject to limits\n<\/p><\/td><\/tr><tr><td><p>\n  Upload XML theme, edit theme HTML\n<\/p><\/td><td><p>\n  No\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><\/tr><tr><td><p>\n  Layout, gadgets, CSS, favicon\n<\/p><\/td><td><p>\n  No\n<\/p><\/td><td><p>\n  Yes\n<\/p><\/td><\/tr><tr><td><p>\n  Upload image binaries\n<\/p><\/td><td><p>\n  No public upload API\n<\/p><\/td><td><p>\n  Yes, supported UI\n<\/p><\/td><\/tr><tr><td><p>\n  Custom domains, HTTPS, permissions\n<\/p><\/td><td><p>\n  No\n<\/p><\/td><td><p>\n  Yes, plus DNS where needed\n<\/p><\/td><\/tr><tr><td><p>\n  Post SEO description, custom slug\n<\/p><\/td><td><p>\n  Not exposed as dedicated write fields\n<\/p><\/td><td><p>\n  Yes, where available\n<\/p><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Which approach should you choose?<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><p><strong>Approach<\/strong>\n<\/p><\/th><th><p><strong>Best use<\/strong>\n<\/p><\/th><\/tr><\/thead><tbody><tr><td><p>\n  REST API \/ Python \/ Node.js \/ PHP\n<\/p><\/td><td><p>\n  Repeatable content operations\n<\/p><\/td><\/tr><tr><td><p>\n  Claude Code \/ Codex\n<\/p><\/td><td><p>\n  Build, test and operate automation\n<\/p><\/td><\/tr><tr><td><p>\n  Playwright \/ Selenium\n<\/p><\/td><td><p>\n  UI-only administration, supervised\n<\/p><\/td><\/tr><tr><td><p>\n  Apps Script \/ n8n \/ CI\n<\/p><\/td><td><p>\n  Recurring workflow orchestration\n<\/p><\/td><\/tr><tr><td><p>\n  Custom MCP server\n<\/p><\/td><td><p>\n  Reusable controlled tools for agents\n<\/p><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\n  The Blogger API does not give the AI agent special permissions. It acts with the permissions of the consenting Google user. See the API reference in the resource section.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2. Architecture: API-first, browser second<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"560\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/ai-coding-agent-sends-approved-jobs-to-blogger-res.png\" alt=\"AI coding agent sends approved jobs to Blogger REST API for content and Playwright for theme administration\" class=\"wp-image-80349\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/ai-coding-agent-sends-approved-jobs-to-blogger-res.png 1200w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/ai-coding-agent-sends-approved-jobs-to-blogger-res-300x140.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/ai-coding-agent-sends-approved-jobs-to-blogger-res-1024x478.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/ai-coding-agent-sends-approved-jobs-to-blogger-res-768x358.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"caption wp-block-paragraph\">\n  Figure 1. Recommended separation between supported API operations and dashboard-only workflows.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Use a single content pipeline with an allowlist of blog IDs, a per-account credential store, approved content, and audit records. Keep the theme worker isolated from the publishing service because it requires more privileged browser access.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Suggested project structure<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-1\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">blogger-automation\/\n  blogger_cli.py        <span class=\"hljs-comment\"># API client and CLI<\/span>\n  blogger_mcp.py        <span class=\"hljs-comment\"># optional controlled MCP tools<\/span>\n  theme_session.py      <span class=\"hljs-comment\"># local authenticated browser<\/span>\n  content\/             <span class=\"hljs-comment\"># reviewed HTML articles<\/span>\n  themes\/              <span class=\"hljs-comment\"># version-controlled XML<\/span>\n  backups\/             <span class=\"hljs-comment\"># protected theme snapshots<\/span>\n  jobs.csv             <span class=\"hljs-comment\"># approved editorial jobs<\/span>\n  .gitignore           <span class=\"hljs-comment\"># exclude credentials and state<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-1\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Prerequisites<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  A Google account with author or administrator access to a test Blogger site; a Google Cloud project; Python 3.10+; an installed Claude Code or Codex CLI if desired; and a local browser for interactive consent and theme work. Create a disposable test blog manually at blogger.com before production use.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3. Enable Blogger API and configure OAuth<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  1. Open Google Cloud Console and create or select a project.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  2. In APIs &amp; Services \u2192 Library, search for Blogger API v3 and enable it.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  3. Open Google Auth Platform (or OAuth consent screen). Set Branding, Audience and Data Access as applicable. Choose External for ordinary consumer Google accounts, or Internal only if eligible in your Workspace organization.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  4. If using Testing mode, add your own Google account as a test user.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  5. Under Clients or Credentials, create an OAuth client of type Desktop app. Download the JSON client configuration and save it locally as credentials.json.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  6. Request the Blogger scope below. For read-only reporting, request blogger.readonly instead. Authorize from a normal local browser and consent only to the required scopes.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-2\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">https:<span class=\"hljs-comment\">\/\/www.googleapis.com\/auth\/blogger<\/span>\nhttps:<span class=\"hljs-comment\">\/\/www.googleapis.com\/auth\/blogger.readonly<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-2\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Install local dependencies<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">mkdir -p blogger-automation &amp;&amp; cd blogger-automation\npython3 -m venv .venv\nsource .venv\/bin\/activate\npython -m pip install google-api-python-client \\\n  google-auth-oauthlib google-auth-httplib2 requests\numask 077<\/code><\/span><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  On Windows use .venv\\Scripts\\activate (Command Prompt) or .venv\\Scripts\\Activate.ps1 (PowerShell). Save the downloaded credentials.json in the project directory. Do not commit it or the resulting token.json.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">OAuth lifecycle and limitations<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  An API key can identify a project for public reads, but publishing requires user OAuth authorization. A refresh token may enable subsequent runs without interactive login. External applications in Testing generally receive refresh tokens that expire after seven days for Blogger scopes. For ongoing use, review production publishing status and any verification requirements; tokens can still be revoked or expire for other reasons. Do not assume a service account has access to a personal Blogger blog.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4. Build the Python Blogger CLI: authentication<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Create blogger_cli.py. The next two sections form one file: copy these blocks in order. This local example stores an OAuth token with restricted file permissions; production should use a managed secret store.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-3\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">import<\/span> argparse\n<span class=\"hljs-keyword\">import<\/span> json\n<span class=\"hljs-keyword\">import<\/span> os\n<span class=\"hljs-keyword\">from<\/span> pathlib <span class=\"hljs-keyword\">import<\/span> Path\n<span class=\"hljs-keyword\">from<\/span> google.auth.transport.requests <span class=\"hljs-keyword\">import<\/span> Request\n<span class=\"hljs-keyword\">from<\/span> google.oauth2.credentials <span class=\"hljs-keyword\">import<\/span> Credentials\n<span class=\"hljs-keyword\">from<\/span> google_auth_oauthlib.flow <span class=\"hljs-keyword\">import<\/span> InstalledAppFlow\n<span class=\"hljs-keyword\">from<\/span> googleapiclient.discovery <span class=\"hljs-keyword\">import<\/span> build\n\nBASE = Path(__file__).resolve().parent\nSCOPE = &#91;<span class=\"hljs-string\">\"https:\/\/www.googleapis.com\/auth\/blogger\"<\/span>]\nTOKEN = BASE \/ <span class=\"hljs-string\">\"token.json\"<\/span>\nCLIENT = BASE \/ <span class=\"hljs-string\">\"credentials.json\"<\/span>\n\ndef service(interactive=False):\n    creds = None\n    <span class=\"hljs-keyword\">if<\/span> TOKEN.exists():\n        creds = Credentials.from_authorized_user_file(\n            str(TOKEN), SCOPE)\n    <span class=\"hljs-keyword\">if<\/span> creds and creds.expired and creds.refresh_token:\n        creds.refresh(Request())\n    <span class=\"hljs-keyword\">if<\/span> not creds or not creds.valid:\n        <span class=\"hljs-keyword\">if<\/span> not interactive:\n            raise RuntimeError(<span class=\"hljs-string\">\"Run auth locally first\"<\/span>)\n        flow = InstalledAppFlow.from_client_secrets_file(\n            str(CLIENT), SCOPE)\n        creds = flow.run_local_server(port=<span class=\"hljs-number\">0<\/span>)\n    os.umask(<span class=\"hljs-number\">0o077<\/span>)\n    TOKEN.write_text(creds.to_json(), encoding=<span class=\"hljs-string\">\"utf-8\"<\/span>)\n    TOKEN.chmod(<span class=\"hljs-number\">0o600<\/span>)\n    <span class=\"hljs-keyword\">return<\/span> build(<span class=\"hljs-string\">\"blogger\"<\/span>, <span class=\"hljs-string\">\"v3\"<\/span>, credentials=creds,\n                 cache_discovery=False)\n\ndef show(data):\n    print(json.dumps(data, indent=<span class=\"hljs-number\">2<\/span>, ensure_ascii=False))<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-3\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Security note<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  For multiple accounts, use separate credential directories or a secret-store lookup per account. Never send refresh tokens, browser cookies or Google passwords to an AI chat. If a refresh fails with invalid_grant, investigate revocation or expiration and authorize again through the legitimate consent flow.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5. Build the Python Blogger CLI: content commands<\/h2>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-4\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">def main():\n    ap = argparse.ArgumentParser()\n    ap.add_argument(<span class=\"hljs-string\">\"action\"<\/span>, choices=&#91;<span class=\"hljs-string\">\"auth\"<\/span>, <span class=\"hljs-string\">\"blogs\"<\/span>, <span class=\"hljs-string\">\"list\"<\/span>,\n        <span class=\"hljs-string\">\"draft\"<\/span>, <span class=\"hljs-string\">\"get\"<\/span>, <span class=\"hljs-string\">\"publish\"<\/span>, <span class=\"hljs-string\">\"revert\"<\/span>, <span class=\"hljs-string\">\"patch\"<\/span>])\n    ap.add_argument(<span class=\"hljs-string\">\"--blog\"<\/span>)\n    ap.add_argument(<span class=\"hljs-string\">\"--post\"<\/span>)\n    ap.add_argument(<span class=\"hljs-string\">\"--title\"<\/span>)\n    ap.add_argument(<span class=\"hljs-string\">\"--html\"<\/span>, type=Path)\n    ap.add_argument(<span class=\"hljs-string\">\"--labels\"<\/span>, <span class=\"hljs-keyword\">default<\/span>=<span class=\"hljs-string\">\"\"<\/span>)\n    ap.add_argument(<span class=\"hljs-string\">\"--date\"<\/span>)\n    ap.add_argument(<span class=\"hljs-string\">\"--confirm\"<\/span>, action=<span class=\"hljs-string\">\"store_true\"<\/span>)\n    a = ap.parse_args()\n    <span class=\"hljs-keyword\">if<\/span> a.action == <span class=\"hljs-string\">\"auth\"<\/span>:\n        service(interactive=<span class=\"hljs-keyword\">True<\/span>)\n        <span class=\"hljs-keyword\">print<\/span>(<span class=\"hljs-string\">\"OAuth ready\"<\/span>)\n        <span class=\"hljs-keyword\">return<\/span>\n    api = service()\n    <span class=\"hljs-keyword\">if<\/span> a.action == <span class=\"hljs-string\">\"blogs\"<\/span>:\n        show(api.blogs().listByUser(userId=<span class=\"hljs-string\">\"self\"<\/span>).execute())\n        <span class=\"hljs-keyword\">return<\/span>\n    <span class=\"hljs-keyword\">if<\/span> not a.blog:\n        ap.error(<span class=\"hljs-string\">\"--blog is required\"<\/span>)\n    posts = api.posts()\n    ids = {<span class=\"hljs-string\">\"blogId\"<\/span>: a.blog}\n    <span class=\"hljs-keyword\">if<\/span> a.action in {<span class=\"hljs-string\">\"get\"<\/span>, <span class=\"hljs-string\">\"publish\"<\/span>, <span class=\"hljs-string\">\"revert\"<\/span>, <span class=\"hljs-string\">\"patch\"<\/span>}:\n        <span class=\"hljs-keyword\">if<\/span> not a.post:\n            ap.error(<span class=\"hljs-string\">\"--post is required\"<\/span>)\n        ids&#91;<span class=\"hljs-string\">\"postId\"<\/span>] = a.post\n    <span class=\"hljs-keyword\">if<\/span> a.action == <span class=\"hljs-string\">\"list\"<\/span>:\n        show(posts.<span class=\"hljs-keyword\">list<\/span>(**ids, fetchBodies=<span class=\"hljs-keyword\">False<\/span>,\n                        view=<span class=\"hljs-string\">\"ADMIN\"<\/span>).execute())\n    elif a.action == <span class=\"hljs-string\">\"draft\"<\/span>:\n        <span class=\"hljs-keyword\">if<\/span> not a.title <span class=\"hljs-keyword\">or<\/span> not a.html:\n            ap.error(<span class=\"hljs-string\">\"--title and --html are required\"<\/span>)\n        body = {<span class=\"hljs-string\">\"title\"<\/span>: a.title, <span class=\"hljs-string\">\"content\"<\/span>: a.html.read_text(),\n                <span class=\"hljs-string\">\"labels\"<\/span>: &#91;x.strip() <span class=\"hljs-keyword\">for<\/span> x in a.labels.split(<span class=\"hljs-string\">\",\"<\/span>)\n                           <span class=\"hljs-keyword\">if<\/span> x.strip()]}\n        show(posts.insert(**ids, body=body, isDraft=<span class=\"hljs-keyword\">True<\/span>).execute())\n    elif a.action == <span class=\"hljs-string\">\"get\"<\/span>:\n        show(posts.get(**ids, view=<span class=\"hljs-string\">\"ADMIN\"<\/span>).execute())\n    <span class=\"hljs-keyword\">else<\/span>:\n        <span class=\"hljs-keyword\">if<\/span> not a.confirm:\n            ap.error(<span class=\"hljs-string\">\"Review target and supply --confirm\"<\/span>)\n        <span class=\"hljs-keyword\">if<\/span> a.action == <span class=\"hljs-string\">\"publish\"<\/span>:\n            <span class=\"hljs-keyword\">if<\/span> a.date: ids&#91;<span class=\"hljs-string\">\"publishDate\"<\/span>] = a.date\n            show(posts.publish(**ids).execute())\n        elif a.action == <span class=\"hljs-string\">\"revert\"<\/span>:\n            show(posts.revert(**ids).execute())\n        elif a.action == <span class=\"hljs-string\">\"patch\"<\/span>:\n            <span class=\"hljs-keyword\">if<\/span> not a.html: ap.error(<span class=\"hljs-string\">\"--html is required\"<\/span>)\n            show(posts.patch(**ids, body={\n                <span class=\"hljs-string\">\"content\"<\/span>: a.html.read_text()}).execute())\n\n<span class=\"hljs-keyword\">if<\/span> __name__ == <span class=\"hljs-string\">\"__main__\"<\/span>:\n    main()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-4\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  This starter deliberately omits delete and bulk publishing. The list command returns one page; production reporting must follow nextPageToken until exhausted. The confirmation flag is a local CLI safeguard, not a substitute for an actual approval system.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">6. First working exercise: draft, publish and verify<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Use a test blog rather than a production property. The commands below are for macOS\/Linux. Copy actual IDs from API responses; IDs should be handled as strings.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-5\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">python blogger_cli.py auth\npython blogger_cli.py blogs\nexport BLOG_ID=<span class=\"hljs-string\">'YOUR_TEST_BLOG_ID'<\/span>\nmkdir -p content\ncat &gt; content\/hello.html &lt;&lt;<span class=\"hljs-string\">'EOF'<\/span>\n&lt;h2&gt;Hello Blogger API&lt;\/h2&gt;\n&lt;p&gt;This is a test article created through the API.&lt;\/p&gt;\n&lt;p&gt;It demonstrates a draft-first publishing workflow.&lt;\/p&gt;\nEOF\npython blogger_cli.py draft --blog <span class=\"hljs-string\">\"$BLOG_ID\"<\/span> \\\n  --title <span class=\"hljs-string\">\"Hello Blogger API\"<\/span> --html content\/hello.html \\\n  --labels <span class=\"hljs-string\">\"Automation, Tutorial\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-5\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  Expected result: JSON containing a post id, title and draft status. In Blogger, open Posts and confirm the draft exists. Copy its ID to the variable below.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-6\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">export POST_ID=<span class=\"hljs-string\">'RETURNED_POST_ID'<\/span>\npython blogger_cli.py get --blog <span class=\"hljs-string\">\"$BLOG_ID\"<\/span> --post <span class=\"hljs-string\">\"$POST_ID\"<\/span>\npython blogger_cli.py publish --blog <span class=\"hljs-string\">\"$BLOG_ID\"<\/span> \\\n  --post <span class=\"hljs-string\">\"$POST_ID\"<\/span> --confirm\npython blogger_cli.py get --blog <span class=\"hljs-string\">\"$BLOG_ID\"<\/span> --post <span class=\"hljs-string\">\"$POST_ID\"<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-6\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  Expected result: the post is published and its API response includes a URL. Open that URL in a private browser tab and verify the title and article. A private blog may require login; do not assume public access. To undo the public publication without deleting the article:\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-7\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">python blogger_cli.py revert --blog <span class=\"hljs-string\">\"$BLOG_ID\"<\/span> \\\n  --post <span class=\"hljs-string\">\"$POST_ID\"<\/span> --confirm<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-7\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Schedule a draft and update an existing article<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-8\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Set an RFC 3339 timestamp in the future before running.<\/span>\nexport PUBLISH_AT=<span class=\"hljs-string\">'2027-01-10T09:00:00+09:00'<\/span>\npython blogger_cli.py publish --blog <span class=\"hljs-string\">\"$BLOG_ID\"<\/span> \\\n  --post <span class=\"hljs-string\">\"$POST_ID\"<\/span> --date <span class=\"hljs-string\">\"$PUBLISH_AT\"<\/span> --confirm\n<span class=\"hljs-comment\"># Edit the HTML file first, then patch content.<\/span>\npython blogger_cli.py patch --blog <span class=\"hljs-string\">\"$BLOG_ID\"<\/span> \\\n  --post <span class=\"hljs-string\">\"$POST_ID\"<\/span> --html content\/hello.html --confirm<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-8\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  A publish date is supplied to the publish endpoint. Inspect the returned status and verify the scheduled date in the dashboard. Use a future time appropriate to your test.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">7. REST API reference and direct cURL usage<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Base URL: https:\/\/www.googleapis.com\/blogger\/v3. In the table, B = blog ID, P = post ID, C = comment ID, A = page ID, U = user ID (self for the current user). Use OAuth for protected operations.\n<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><p><strong>Method<\/strong>\n<\/p><\/th><th><p><strong>Relative path<\/strong>\n<\/p><\/th><th><p><strong>Purpose<\/strong>\n<\/p><\/th><\/tr><\/thead><tbody><tr><td><p>\n  GET\n<\/p><\/td><td><p>\n  \/users\/U\/blogs\n<\/p><\/td><td><p>\n  Discover blogs\n<\/p><\/td><\/tr><tr><td><p>\n  GET\n<\/p><\/td><td><p>\n  \/blogs\/B\n<\/p><\/td><td><p>\n  Blog metadata\n<\/p><\/td><\/tr><tr><td><p>\n  GET\n<\/p><\/td><td><p>\n  \/blogs\/byurl?url=\u2026\n<\/p><\/td><td><p>\n  Resolve blog by URL\n<\/p><\/td><\/tr><tr><td><p>\n  GET \/ POST\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\n<\/p><\/td><td><p>\n  List \/ insert\n<\/p><\/td><\/tr><tr><td><p>\n  GET \/ PATCH \/ PUT \/ DELETE\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/P\n<\/p><\/td><td><p>\n  Read \/ edit \/ remove\n<\/p><\/td><\/tr><tr><td><p>\n  GET\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/search?q=\u2026\n<\/p><\/td><td><p>\n  Search posts\n<\/p><\/td><\/tr><tr><td><p>\n  GET\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/bypath?path=\u2026\n<\/p><\/td><td><p>\n  Find by path\n<\/p><\/td><\/tr><tr><td><p>\n  POST\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/P\/publish\n<\/p><\/td><td><p>\n  Publish \/ schedule\n<\/p><\/td><\/tr><tr><td><p>\n  POST\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/P\/revert\n<\/p><\/td><td><p>\n  Return to draft\n<\/p><\/td><\/tr><tr><td><p>\n  GET \/ POST\n<\/p><\/td><td><p>\n  \/blogs\/B\/pages\n<\/p><\/td><td><p>\n  List \/ insert pages\n<\/p><\/td><\/tr><tr><td><p>\n  GET \/ PATCH \/ PUT \/ DELETE\n<\/p><\/td><td><p>\n  \/blogs\/B\/pages\/A\n<\/p><\/td><td><p>\n  Manage page\n<\/p><\/td><\/tr><tr><td><p>\n  GET\n<\/p><\/td><td><p>\n  \/blogs\/B\/comments\n<\/p><\/td><td><p>\n  Comments across blog\n<\/p><\/td><\/tr><tr><td><p>\n  GET\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/P\/comments\n<\/p><\/td><td><p>\n  Comments on post\n<\/p><\/td><\/tr><tr><td><p>\n  GET \/ DELETE\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/P\/comments\/C\n<\/p><\/td><td><p>\n  Read \/ remove comment\n<\/p><\/td><\/tr><tr><td><p>\n  POST\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/P\/comments\/C\/approve\n<\/p><\/td><td><p>\n  Approve comment\n<\/p><\/td><\/tr><tr><td><p>\n  POST\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/P\/comments\/C\/spam\n<\/p><\/td><td><p>\n  Mark as spam\n<\/p><\/td><\/tr><tr><td><p>\n  POST\n<\/p><\/td><td><p>\n  \/blogs\/B\/posts\/P\/comments\/C\/removecontent\n<\/p><\/td><td><p>\n  Remove content\n<\/p><\/td><\/tr><tr><td><p>\n  GET\n<\/p><\/td><td><p>\n  \/blogs\/B\/pageviews\n<\/p><\/td><td><p>\n  Pageview stats\n<\/p><\/td><\/tr><tr><td><p>\n  GET\n<\/p><\/td><td><p>\n  \/users\/U\n<\/p><\/td><td><p>\n  User info\n<\/p><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Create a draft with cURL<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-9\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># ACCESS_TOKEN must be a valid OAuth access token.<\/span>\ncurl --fail-with-body -X POST \\\n  <span class=\"hljs-string\">\"https:\/\/www.googleapis.com\/blogger\/v3\/blogs\/$BLOG_ID\/posts?isDraft=true\"<\/span> \\\n  -H <span class=\"hljs-string\">\"Authorization: Bearer $ACCESS_TOKEN\"<\/span> \\\n  -H <span class=\"hljs-string\">'Content-Type: application\/json'<\/span> \\\n  -d <span class=\"hljs-string\">'{\"title\":\"REST example\",\"content\":\"&lt;p&gt;Hello&lt;\/p&gt;\"}'<\/span> <\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-9\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  Use PATCH when only selected fields need changes. PUT can replace more of a resource. Deletion is destructive: export and verify the target before using it.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">8. Pages, comments, images and HTML content<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  The following examples run in a Python shell or a separate script alongside blogger_cli.py. Replace identifiers with your test IDs. Page creation may make the page visible, so use a test blog. Comments should be moderated rather than automatically erased.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-10\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">from blogger_cli import service\napi = service()\nB = <span class=\"hljs-string\">\"YOUR_TEST_BLOG_ID\"<\/span>\nP = <span class=\"hljs-string\">\"YOUR_POST_ID\"<\/span>\n<span class=\"hljs-comment\"># Static page<\/span>\npage = api.pages().insert(blogId=B, body={\n    <span class=\"hljs-string\">\"title\"<\/span>: <span class=\"hljs-string\">\"About this blog\"<\/span>,\n    <span class=\"hljs-string\">\"content\"<\/span>: <span class=\"hljs-string\">\"&lt;p&gt;Independent tutorials and examples.&lt;\/p&gt;\"<\/span>\n}).execute()\n<span class=\"hljs-keyword\">print<\/span>(page&#91;<span class=\"hljs-string\">\"id\"<\/span>])\n<span class=\"hljs-comment\"># Inspect comments; repeat with pageToken as needed.<\/span>\ncomments = api.comments().<span class=\"hljs-keyword\">list<\/span>(blogId=B, postId=P).execute()\n<span class=\"hljs-keyword\">for<\/span> c in comments.get(<span class=\"hljs-string\">\"items\"<\/span>, &#91;]):\n    <span class=\"hljs-keyword\">print<\/span>(c&#91;<span class=\"hljs-string\">\"id\"<\/span>], c.get(<span class=\"hljs-string\">\"status\"<\/span>))\n<span class=\"hljs-comment\"># Only after review: approve the chosen comment.<\/span>\n<span class=\"hljs-comment\"># api.comments().approve(blogId=B, postId=P,<\/span>\n<span class=\"hljs-comment\">#     commentId=\"REVIEWED_COMMENT_ID\").execute()<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-10\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">How to add images, links, tables and code<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-11\" data-shcb-language-name=\"HTML, XML\" data-shcb-language-slug=\"xml\"><span><code class=\"hljs language-xml\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h2<\/span>&gt;<\/span>Architecture<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h2<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span>Read the <span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"https:\/\/developers.google.com\/blogger\/\"<\/span>&gt;<\/span>\nBlogger API documentation<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">a<\/span>&gt;<\/span>.<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">img<\/span> <span class=\"hljs-attr\">src<\/span>=<span class=\"hljs-string\">\"https:\/\/your-image-host.example\/diagram.png\"<\/span>\n     <span class=\"hljs-attr\">alt<\/span>=<span class=\"hljs-string\">\"Blogger content automation architecture\"<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">pre<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">code<\/span>&gt;<\/span>python blogger_cli.py blogs<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">code<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">pre<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">table<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">tr<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">th<\/span>&gt;<\/span>Method<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">th<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">th<\/span>&gt;<\/span>Purpose<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">th<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">tr<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">tr<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">td<\/span>&gt;<\/span>GET<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">td<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">td<\/span>&gt;<\/span>Read content<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">td<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">tr<\/span>&gt;<\/span><span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">table<\/span>&gt;<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-11\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">HTML, XML<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">xml<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  Replace the illustrative image URL with a real, public HTTPS image hosted on a service you control or are authorized to use. Blogger API does not expose binary image uploads. The dashboard can upload images, or use object storage\/CDN with stable links. Sanitize HTML and avoid arbitrary scripts, hidden links and unsafe embeds. Preview mobile and desktop rendering.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">SEO fields and URL limitations<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  The API exposes core post data such as title, content and labels, but does not provide a documented dedicated write field for every Blogger editor SEO option. Set custom permalink or search description in the dashboard when required; verify canonical URLs rather than assuming the generated slug. A blog theme controls much of the presentation.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">9. Automate using Claude Code and OpenAI Codex<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Claude Code and Codex are coding agents, not Blogger APIs. They can write scripts, inspect a repository, execute allowed commands, and assist with error handling. Run locally for this workflow because consent and browser session data should remain under your control.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-12\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># From the project root, after installing and signing in<\/span>\nclaude --version\ncodex --version\n<span class=\"hljs-comment\"># Start whichever agent you use<\/span>\nclaude\n<span class=\"hljs-comment\"># or<\/span>\ncodex<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-12\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Copy-ready implementation prompt for either agent<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-13\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">Study <span class=\"hljs-keyword\">this<\/span> repository and the official Blogger API v3 docs.\nImplement a Python CLI to list authorized blogs, create drafts,\nread and patch posts, schedule approved drafts and revert posts.\nUse OAuth, an explicit blog allowlist and secret-safe logging.\nAdd unit tests using mocked Google API responses, pagination,\nretry logic <span class=\"hljs-keyword\">for<\/span> transient errors and duplicate-job protection.\nDo not read or print credential files or browser cookies.\nNever publish, <span class=\"hljs-keyword\">delete<\/span> or modify a theme without human approval.\nProvide a dry-run mode and demonstrate against a test blog.\nUse Playwright only <span class=\"hljs-keyword\">for<\/span> UI operations missing <span class=\"hljs-keyword\">from<\/span> the API.\nRecord selectors on the real UI and stop on login challenges.\nDocument how to back up, deploy, verify and roll back themes.\nDo not use private Blogger endpoints or bypass security controls.<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-13\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Working with repository instructions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Save durable constraints in CLAUDE.md and AGENTS.md as appropriate to your agent. Give the agent a test environment, not unrestricted production credentials. Inspect proposed changes and test output. Treat blog HTML and third-party content as untrusted data, not instructions for the agent.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Example tasks<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><br>    List the authorized blogs and summarize IDs and URLs; make no changes.<br>  <\/li>\n\n\n\n<li><br>    Generate an original tutorial as local HTML and create one draft in the test blog.<br>  <\/li>\n\n\n\n<li><br>    Review this XML theme for broken markup, insecure scripts and missing layout elements; do not deploy.<br>  <\/li>\n\n\n\n<li><br>    Run tests and report which jobs failed without blindly retrying writes.<br>  <\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">10. Optional: expose Blogger tools through MCP<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Model Context Protocol (MCP) lets an AI client call narrowly scoped tools rather than assembling arbitrary shell commands. Start with blog discovery and draft creation. The example uses the v1 Python MCP SDK API, pinned below because the v2 SDK has a different interface.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-14\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">python -m pip install <span class=\"hljs-string\">'mcp&gt;=1,&lt;2'<\/span>\n<span class=\"hljs-comment\"># Create blogger_mcp.py alongside blogger_cli.py.<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-14\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-15\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-keyword\">from<\/span> mcp.server.fastmcp <span class=\"hljs-keyword\">import<\/span> FastMCP\n<span class=\"hljs-keyword\">from<\/span> blogger_cli <span class=\"hljs-keyword\">import<\/span> service\n\nmcp = FastMCP(<span class=\"hljs-string\">\"blogger-local\"<\/span>)\nALLOWED = {<span class=\"hljs-string\">\"REPLACE_WITH_TEST_BLOG_ID\"<\/span>}\n\n@mcp.tool()\ndef list_blogs() -&gt; dict:\n    <span class=\"hljs-string\">\"\"<\/span><span class=\"hljs-string\">\"List blogs available to the authorized account.\"<\/span><span class=\"hljs-string\">\"\"<\/span>\n    <span class=\"hljs-keyword\">return<\/span> service().blogs().listByUser(userId=<span class=\"hljs-string\">\"self\"<\/span>).execute()\n\n@mcp.tool()\ndef create_draft(blog_id: str, <span class=\"hljs-attr\">title<\/span>: str, <span class=\"hljs-attr\">html<\/span>: str) -&gt; dict:\n    <span class=\"hljs-string\">\"\"<\/span><span class=\"hljs-string\">\"Create a draft only in an explicitly allowed blog.\"<\/span><span class=\"hljs-string\">\"\"<\/span>\n    <span class=\"hljs-keyword\">if<\/span> blog_id not <span class=\"hljs-keyword\">in<\/span> ALLOWED:\n        raise ValueError(<span class=\"hljs-string\">\"Blog not approved\"<\/span>)\n    <span class=\"hljs-keyword\">if<\/span> not title.strip() or not html.strip():\n        raise ValueError(<span class=\"hljs-string\">\"Title and HTML are required\"<\/span>)\n    result = service().posts().insert(blogId=blog_id,\n        isDraft=True, body={<span class=\"hljs-string\">\"title\"<\/span>: title,\n                           <span class=\"hljs-string\">\"content\"<\/span>: html}).execute()\n    <span class=\"hljs-keyword\">return<\/span> {<span class=\"hljs-string\">\"id\"<\/span>: result&#91;<span class=\"hljs-string\">\"id\"<\/span>], <span class=\"hljs-string\">\"title\"<\/span>: result.get(<span class=\"hljs-string\">\"title\"<\/span>)}\n\n<span class=\"hljs-keyword\">if<\/span> __name__ == <span class=\"hljs-string\">\"__main__\"<\/span>:\n    mcp.run(transport=<span class=\"hljs-string\">\"stdio\"<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-15\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Register the local server<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-16\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Replace the absolute path with your project location.<\/span>\nclaude mcp add --transport stdio blogger -- \\\n  \/absolute\/project\/.venv\/bin\/python \/absolute\/project\/blogger_mcp.py\ncodex mcp add blogger -- \\\n  \/absolute\/project\/.venv\/bin\/python \/absolute\/project\/blogger_mcp.py\nclaude mcp <span class=\"hljs-keyword\">list<\/span>\ncodex mcp <span class=\"hljs-keyword\">list<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-16\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  Authorize the CLI first, update the allowlist, then ask the agent to list blogs or create one reviewed test draft. For production, add schema validation, HTML sanitization, job deduplication, audit logging and a trusted approval service before adding publish tools. Do not expose raw tokens or generic command execution over MCP.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">11. Upload a Blogger XML theme: manual method<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  There is no theme upload endpoint in Blogger API v3. Theme XML is distinct from the blog content export. The supported administration surface is the dashboard; uploading a compatible template through Restore is a commonly used workflow. Third-party templates may need editing or vendor support.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step-by-step theme deployment<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  1. Sign in at blogger.com using the authorized administrator account and choose the test blog.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  2. Open Theme. Use the dropdown or more-options control near Customize \/ My theme. Choose Backup and download the current XML.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  3. Store the backup securely with blog ID, date and theme version. Also back up content separately if the change is important.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  4. Select Restore from the theme dropdown, choose Upload, and select the compatible XML file. If your interface differs, use the available Theme controls or Edit HTML for a reviewed template.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  5. Check the dashboard for success or XML parsing errors. Open the public homepage and at least one article, page and label archive on desktop and mobile.\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\n  6. If validation fails, stop rollout and restore the previously downloaded XML using the same workflow. Review widgets and settings separately if needed.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Theme validation and maintenance<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><br>    Use trusted Blogger-compatible XML, not a WordPress theme ZIP. Test all XML changes in a disposable blog.<br>  <\/li>\n\n\n\n<li><br>    Check XML well-formedness, escaped ampersands, namespaces, widgets, responsive CSS, template expressions and external JavaScript.<br>  <\/li>\n\n\n\n<li><br>    Compare title tags, canonical URLs, robots directives, navigation, schema markup, fonts and accessibility.<br>  <\/li>\n\n\n\n<li><br>    Preserve site verification tags, analytics and important widgets. Remove unknown or suspicious scripts.<br>  <\/li>\n<\/ul>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-17\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Basic well-formedness check; not a Blogger schema validator.<\/span>\npython -c <span class=\"hljs-string\">'import xml.etree.ElementTree as E; E.parse(\"themes\/theme.xml\"); print(\"XML parsed\")'<\/span> <\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-17\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  Parsing XML does not prove Blogger compatibility or security. Theme changes can affect SEO and user experience, even when the API content remains untouched. Keep a known-good backup and test before each rollout.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">12. Playwright automation for XML theme uploads<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Playwright can interact with the same dashboard controls as an administrator. It is not an official Blogger theme API. Use a dedicated local browser profile, let the user authenticate manually, and stop if Google blocks the session or requests additional verification. Never bypass CAPTCHA or MFA.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-18\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">python -m pip install playwright\npython -m playwright install chromium\nmkdir -p backups themes\n<span class=\"hljs-comment\"># Record the actual dashboard selectors in an interactive session.<\/span>\npython -m playwright codegen https:<span class=\"hljs-comment\">\/\/www.blogger.com\/<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-18\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Create a dedicated local browser session<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-19\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># theme_session.py<\/span>\nfrom pathlib import Path\nfrom playwright.sync_api import sync_playwright\n\nroot = Path(<span class=\"hljs-keyword\">__file__<\/span>).resolve().<span class=\"hljs-keyword\">parent<\/span>\nwith sync_playwright() <span class=\"hljs-keyword\">as<\/span> pw:\n    ctx = pw.chromium.launch_persistent_context(\n        str(root \/ <span class=\"hljs-string\">\".browser-profile\"<\/span>), headless=<span class=\"hljs-keyword\">False<\/span>,\n        accept_downloads=<span class=\"hljs-keyword\">True<\/span>)\n    <span class=\"hljs-keyword\">try<\/span>:\n        page = ctx.pages&#91;<span class=\"hljs-number\">0<\/span>] <span class=\"hljs-keyword\">if<\/span> ctx.pages <span class=\"hljs-keyword\">else<\/span> ctx.new_page()\n        page.<span class=\"hljs-keyword\">goto<\/span>(<span class=\"hljs-string\">\"https:\/\/www.blogger.com\/\"<\/span>)\n        input(<span class=\"hljs-string\">\"Sign in manually and select test blog; press Enter: \"<\/span>)\n        <span class=\"hljs-comment\"># Inspect \/ record actual selectors, then automate.<\/span>\n        page.pause()\n    <span class=\"hljs-keyword\">finally<\/span>:\n        ctx.close()<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-19\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-20\" data-shcb-language-name=\"CSS\" data-shcb-language-slug=\"css\"><span><code class=\"hljs language-css\"><span class=\"hljs-selector-tag\">python<\/span> <span class=\"hljs-selector-tag\">theme_session<\/span><span class=\"hljs-selector-class\">.py<\/span><\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-20\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">CSS<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">css<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  Use Playwright Inspector or codegen to record selection of the correct blog, Theme, backup and restore. The browser profile contains sensitive session data. Do not use your primary everyday Chrome profile, and never commit this directory. If the controlled browser cannot sign in, use the ordinary dashboard manually rather than evading Google restrictions.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Why not hardcode selectors?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Blogger dashboard markup, locale, menus and accessibility labels can change. No authenticated dashboard was available for this guide, so the next section is a selector-dependent pattern, not a verified one-click deployment script. First record the controls for your account and locale.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">13. Automate theme backup, upload and rollback<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  After recording the dashboard actions, insert this function into theme_session.py (above the session block). Pass locators discovered in your UI. Select the correct blog and open the Theme menu before calling it. The example intentionally requires local confirmation before replacing a theme.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-21\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\">def deploy_theme(page, theme, backup, backup_menu,\n                 download_button, reopen_menu, restore_menu,\n                 upload_button):\n    from pathlib import Path\n    from xml.etree.ElementTree import parse\n    theme, backup = Path(theme), Path(backup)\n    parse(theme)  <span class=\"hljs-comment\"># Basic XML check<\/span>\n    <span class=\"hljs-keyword\">if<\/span> backup.exists():\n        raise FileExistsError(<span class=\"hljs-string\">\"Use a unique backup filename\"<\/span>)\n    backup.<span class=\"hljs-keyword\">parent<\/span>.mkdir(parents=<span class=\"hljs-keyword\">True<\/span>, exist_ok=<span class=\"hljs-keyword\">True<\/span>)\n    backup_menu.click()\n    with page.expect_download() <span class=\"hljs-keyword\">as<\/span> event:\n        download_button.click()\n    event.value.save_as(str(backup))\n    parse(backup)\n    <span class=\"hljs-keyword\">if<\/span> input(<span class=\"hljs-string\">\"Backup saved. Type DEPLOY to continue: \"<\/span>) != <span class=\"hljs-string\">\"DEPLOY\"<\/span>:\n        <span class=\"hljs-keyword\">return<\/span>\n    reopen_menu.click()\n    restore_menu.click()\n    with page.expect_file_chooser() <span class=\"hljs-keyword\">as<\/span> event:\n        upload_button.click()\n    event.value.set_files(str(theme.resolve()))\n    input(<span class=\"hljs-string\">\"Check upload result in Blogger, then press Enter: \"<\/span>)<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-21\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  Locator parameters are Playwright Locator objects (for example, page.get_by_role(&#8220;button&#8221;, name=&#8221;Upload&#8221;) only if that matches your actual UI). If the dashboard instead exposes an input element, use the alternative below after opening the correct upload dialog.\n<\/p>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-22\" data-shcb-language-name=\"PHP\" data-shcb-language-slug=\"php\"><span><code class=\"hljs language-php\"><span class=\"hljs-comment\"># Use only if inspection confirms the actual file input.<\/span>\npage.locator(<span class=\"hljs-string\">'input&#91;type=\"file\"]'<\/span>).set_input_files(str(theme))<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-22\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">PHP<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">php<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Production rollout controls<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Record the exact blog ID and theme SHA-256, backup location, operator, approval and timestamp. Start with one canary blog, inspect actual page output and only then authorize a small batch. Do not automatically repeat an upload if the outcome is unknown. To roll back, restore the saved XML, recheck widgets and settings, and rerun the same smoke tests. A theme backup does not guarantee recovery of every setting or external asset.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">14. Bulk management and recurring workflows<\/h2>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1200\" height=\"560\" src=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/draft-validation-editorial-approval-publish-ver.png\" alt=\"Draft validation, editorial approval, publish, verify URL, record result and recover on failure\" class=\"wp-image-80350\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/draft-validation-editorial-approval-publish-ver.png 1200w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/draft-validation-editorial-approval-publish-ver-300x140.png 300w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/draft-validation-editorial-approval-publish-ver-1024x478.png 1024w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2026\/11\/draft-validation-editorial-approval-publish-ver-768x358.png 768w\" sizes=\"auto, (max-width: 1200px) 100vw, 1200px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"caption wp-block-paragraph\">\n  Figure 2. Draft-first publication lifecycle and reconciliation.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">CSV job manifest<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-23\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\">job_id,blog_id,title,html_path,approved,publish_at\nj001,TEST_BLOG_ID,API introduction,content\/intro.html,<span class=\"hljs-literal\">false<\/span>,\nj002,TEST_BLOG_ID,Theme guide,content\/theme.html,<span class=\"hljs-literal\">false<\/span>,<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-23\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  The scheduler should read the manifest, reject unknown blog IDs, validate HTML, compute a content hash and create drafts. Store each returned post ID in a durable database. An approved job can then publish or schedule that exact ID; a retry should reconcile the existing post instead of inserting a duplicate.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Alternative automation options<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><p><strong>Option<\/strong>\n<\/p><\/th><th><p><strong>How to use it<\/strong>\n<\/p><\/th><\/tr><\/thead><tbody><tr><td><p>\n  Apps Script\n<\/p><\/td><td><p>\n  Call REST API with UrlFetchApp and ScriptApp.getOAuthToken(); configure scopes, enable API and use time triggers.\n<\/p><\/td><\/tr><tr><td><p>\n  n8n \/ Make\n<\/p><\/td><td><p>\n  Use an HTTP request step with Google OAuth and a separate human approval step.\n<\/p><\/td><\/tr><tr><td><p>\n  GitHub Actions \/ cron\n<\/p><\/td><td><p>\n  Run approved API jobs using protected secrets and a worker; no interactive OAuth during scheduled execution.\n<\/p><\/td><\/tr><tr><td><p>\n  Node.js \/ PHP\n<\/p><\/td><td><p>\n  Use Google client libraries or HTTP with OAuth token refresh; same REST endpoints.\n<\/p><\/td><\/tr><tr><td><p>\n  Selenium\n<\/p><\/td><td><p>\n  UI automation alternative; maintain selectors and handle sessions manually.\n<\/p><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Keep browser theme work on a controlled workstation rather than putting a persistent Google profile into a cloud CI runner. Run one worker per browser profile and isolate each Google account.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">15. Apps Script, scheduler and operational reliability<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  For Google-native scheduling, create an Apps Script project and associate the relevant Google Cloud project with Blogger API enabled. Set the manifest scopes explicitly, run once manually to authorize, and configure a time-driven trigger for an approved job function if needed.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Apps Script manifest fragment (appsscript.json)<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-24\" data-shcb-language-name=\"JSON \/ JSON with Comments\" data-shcb-language-slug=\"json\"><span><code class=\"hljs language-json\">{\n  <span class=\"hljs-attr\">\"timeZone\"<\/span>: <span class=\"hljs-string\">\"Asia\/Tokyo\"<\/span>,\n  <span class=\"hljs-attr\">\"runtimeVersion\"<\/span>: <span class=\"hljs-string\">\"V8\"<\/span>,\n  <span class=\"hljs-attr\">\"oauthScopes\"<\/span>: &#91;\n    <span class=\"hljs-string\">\"https:\/\/www.googleapis.com\/auth\/blogger\"<\/span>,\n    <span class=\"hljs-string\">\"https:\/\/www.googleapis.com\/auth\/script.external_request\"<\/span>\n  ]\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-24\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JSON \/ JSON with Comments<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">json<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Draft-only Apps Script example<\/h3>\n\n\n<pre class=\"wp-block-code\" aria-describedby=\"shcb-language-25\" data-shcb-language-name=\"JavaScript\" data-shcb-language-slug=\"javascript\"><span><code class=\"hljs language-javascript\"><span class=\"hljs-function\"><span class=\"hljs-keyword\">function<\/span> <span class=\"hljs-title\">createTestDraft<\/span>(<span class=\"hljs-params\"><\/span>) <\/span>{\n  <span class=\"hljs-keyword\">const<\/span> blogId = <span class=\"hljs-string\">'YOUR_TEST_BLOG_ID'<\/span>;\n  <span class=\"hljs-keyword\">const<\/span> url = <span class=\"hljs-string\">'https:\/\/www.googleapis.com\/blogger\/v3\/blogs\/'<\/span> +\n              <span class=\"hljs-built_in\">encodeURIComponent<\/span>(blogId) + <span class=\"hljs-string\">'\/posts?isDraft=true'<\/span>;\n  <span class=\"hljs-keyword\">const<\/span> response = UrlFetchApp.fetch(url, {\n    <span class=\"hljs-attr\">method<\/span>: <span class=\"hljs-string\">'post'<\/span>,\n    <span class=\"hljs-attr\">contentType<\/span>: <span class=\"hljs-string\">'application\/json'<\/span>,\n    <span class=\"hljs-attr\">headers<\/span>: {<span class=\"hljs-attr\">Authorization<\/span>: <span class=\"hljs-string\">'Bearer '<\/span> + ScriptApp.getOAuthToken()},\n    <span class=\"hljs-attr\">payload<\/span>: <span class=\"hljs-built_in\">JSON<\/span>.stringify({<span class=\"hljs-attr\">title<\/span>: <span class=\"hljs-string\">'Apps Script test'<\/span>,\n                            <span class=\"hljs-attr\">content<\/span>: <span class=\"hljs-string\">'&lt;p&gt;Hello Blogger&lt;\/p&gt;'<\/span>}),\n    <span class=\"hljs-attr\">muteHttpExceptions<\/span>: <span class=\"hljs-literal\">true<\/span>\n  });\n  <span class=\"hljs-keyword\">if<\/span> (response.getResponseCode() &gt;= <span class=\"hljs-number\">300<\/span>) {\n    <span class=\"hljs-keyword\">throw<\/span> <span class=\"hljs-keyword\">new<\/span> <span class=\"hljs-built_in\">Error<\/span>(<span class=\"hljs-string\">'Blogger status '<\/span> + response.getResponseCode());\n  }\n  <span class=\"hljs-built_in\">console<\/span>.log(<span class=\"hljs-built_in\">JSON<\/span>.parse(response.getContentText()).id);\n}<\/code><\/span><small class=\"shcb-language\" id=\"shcb-language-25\"><span class=\"shcb-language__label\">Code language:<\/span> <span class=\"shcb-language__name\">JavaScript<\/span> <span class=\"shcb-language__paren\">(<\/span><span class=\"shcb-language__slug\">javascript<\/span><span class=\"shcb-language__paren\">)<\/span><\/small><\/pre>\n\n\n<p class=\"wp-block-paragraph\">\n  Run manually once against the test blog. Do not schedule this sample unchanged: every invocation creates a new draft. Add a persistent job ledger, locking and approvals first.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Reliability checklist<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><br>    Inspect project-specific API quotas in Cloud Console; do not assume a universal daily limit. Handle quota errors and keep requests paced.<br>  <\/li>\n\n\n\n<li><br>    Use exponential backoff with jitter for transient reads and verified retryable operations; reconcile uncertain write outcomes before retrying.<br>  <\/li>\n\n\n\n<li><br>    Keep structured logs: job ID, blog ID, post ID, status, attempt count, timestamp and public URL; never log tokens.<br>  <\/li>\n\n\n\n<li><br>    Use an allowlist, least privilege, protected backups, content validation, per-account rate limits and manual approvals for production changes.<br>  <\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">16. Troubleshooting and production security<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><p><strong>Symptom<\/strong>\n<\/p><\/th><th><p><strong>Likely cause \/ action<\/strong>\n<\/p><\/th><\/tr><\/thead><tbody><tr><td><p>\n  401 Unauthorized\n<\/p><\/td><td><p>\n  Access token expired or invalid. Refresh or reauthorize.\n<\/p><\/td><\/tr><tr><td><p>\n  403 Forbidden\n<\/p><\/td><td><p>\n  API disabled, missing scope, role, quota or policy issue. Inspect error reason.\n<\/p><\/td><\/tr><tr><td><p>\n  404 Not Found\n<\/p><\/td><td><p>\n  Incorrect ID, missing resource or unavailable access. Re-list authorized blogs.\n<\/p><\/td><\/tr><tr><td><p>\n  400 Bad Request\n<\/p><\/td><td><p>\n  Invalid data, date or parameter. Inspect response details.\n<\/p><\/td><\/tr><tr><td><p>\n  429 \/ 5xx\n<\/p><\/td><td><p>\n  Throttle or transient server failure. Backoff and reconcile writes.\n<\/p><\/td><\/tr><tr><td><p>\n  invalid_grant\n<\/p><\/td><td><p>\n  Revoked\/expired refresh token or testing-mode lifetime. Re-consent.\n<\/p><\/td><\/tr><tr><td><p>\n  Theme XML rejected\n<\/p><\/td><td><p>\n  Invalid or incompatible template. Validate XML; restore backup if changed.\n<\/p><\/td><\/tr><tr><td><p>\n  Playwright timeout\n<\/p><\/td><td><p>\n  Changed selector, modal or account session. Stop and inspect UI.\n<\/p><\/td><\/tr><tr><td><p>\n  Public URL not found\n<\/p><\/td><td><p>\n  Draft, scheduled status, private blog or changed path. Inspect post status.\n<\/p><\/td><\/tr><tr><td><p>\n  Image missing\n<\/p><\/td><td><p>\n  Bad or private URL, hotlink restriction or markup. Test HTTPS URL.\n<\/p><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Recommended .gitignore<\/h3>\n\n\n<pre class=\"wp-block-code\"><span><code class=\"hljs\">credentials.json\ntoken.json\n.browser-profile\/\nplaywright\/.auth\/\n.env\nbackups\/\n.venv\/\n__pycache__\/<\/code><\/span><\/pre>\n\n\n<h3 class=\"wp-block-heading\">Production test strategy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Mock API calls for unit tests. Exercise authentication and draft creation in a separate account or test blog. Run integration tests for pagination, duplicate-job detection, invalid HTML, expired token, rate limits and interrupted writes. Keep human approval for publication, deletion, theme rollout and account settings. Monitor unexpected changes and revoke credentials when an operator leaves.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">17. SEO, editorial quality and responsible automation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Automation saves repetitive effort, but it is not a ranking shortcut. Google Search evaluates content and links according to its search policies. A Blogger site or backlink does not guarantee higher domain authority, indexing or search placement. Build useful blogs with distinct purposes rather than networks of near-identical pages designed to manufacture links.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Editorial rules for a multi-blog network<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><br>    Write original, useful content with factual checks, source links and a clear audience. Avoid duplicate or thin AI-generated posts.<br>  <\/li>\n\n\n\n<li><br>    Use descriptive titles, sensible headings, relevant links, meaningful image alt text, mobile-friendly layouts and accessible navigation.<br>  <\/li>\n\n\n\n<li><br>    Qualify paid or sponsored links with rel=&#8221;sponsored&#8221; or rel=&#8221;nofollow&#8221; where appropriate. Use rel=&#8221;ugc&#8221; for user-generated links when relevant. Do not automate comment spam or link schemes.<br>  <\/li>\n\n\n\n<li><br>    Check public URLs, search indexing, canonical tags and site health through Search Console. Track readership, engagement and quality rather than link counts alone.<br>  <\/li>\n\n\n\n<li><br>    Follow Blogger content policies and Google Search spam policies. Respect copyright and privacy, and do not bypass platform access or rate restrictions.<br>  <\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Production readiness acceptance checklist<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th><p><strong>Check<\/strong>\n<\/p><\/th><th><p><strong>Pass criteria<\/strong>\n<\/p><\/th><\/tr><\/thead><tbody><tr><td><p>\n  OAuth\n<\/p><\/td><td><p>\n  Authorized test account; token stored securely\n<\/p><\/td><\/tr><tr><td><p>\n  API smoke test\n<\/p><\/td><td><p>\n  Draft created, ID recorded, approved publish verified\n<\/p><\/td><\/tr><tr><td><p>\n  Editorial controls\n<\/p><\/td><td><p>\n  Original content reviewed; correct destination\n<\/p><\/td><\/tr><tr><td><p>\n  Duplicate prevention\n<\/p><\/td><td><p>\n  Same job does not create another post\n<\/p><\/td><\/tr><tr><td><p>\n  Theme deployment\n<\/p><\/td><td><p>\n  Backup saved, test blog verified, rollback rehearsed\n<\/p><\/td><\/tr><tr><td><p>\n  Observability\n<\/p><\/td><td><p>\n  Logs contain IDs and results without credentials\n<\/p><\/td><\/tr><tr><td><p>\n  Recovery\n<\/p><\/td><td><p>\n  Unknown outcomes reconciled; operator can revert\n<\/p><\/td><\/tr><tr><td><p>\n  Governance\n<\/p><\/td><td><p>\n  Least privilege, approvals, platform policy compliance\n<\/p><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\n  For the first release, implement content management only. Add theme operations as a separate, supervised service after the draft and publication pipeline is stable. This limits the blast radius of mistakes.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">18. Frequently asked questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Can Claude Code or Codex publish to Blogger directly?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  They can run an authorized API client or call your MCP tools. They do not gain Blogger permissions merely by being installed.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I create a new Blogspot blog using the API?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  No documented blog creation endpoint exists in v3. Create it through the dashboard; account and platform limits apply.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I upload a theme XML through the API?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  No. Use Theme controls in the dashboard or a supervised browser workflow. Record selectors and back up first.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I use one API project for many blogs?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Yes, provided the authorized user has access to the blogs. Different accounts require their own consent and credentials.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I upload images through Blogger API?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Not as binary media through a documented v3 upload endpoint. Embed accessible image URLs or use the dashboard upload.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I schedule content?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Yes. Create a draft, then use the publish endpoint with a future publishDate. Verify the scheduled result.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Does Blogger support custom domains?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Yes through its dashboard and DNS setup, not the public Blogger API. The exact domain records depend on Blogger\u2019s instructions.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can Blogger run a dynamic PHP or database-backed website?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Not as an arbitrary server-side hosting platform. You can add supported templates, HTML, CSS and client-side scripts, and integrate external services where appropriate.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I use a service account?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Do not assume a service account has a Blogger author identity or access. The supported starting point here is delegated user OAuth.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Is the API free and unlimited?<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Blogger is a hosted service, but API and account quotas still apply. Check your Cloud project quotas and current product policies; external hosting and automation may incur costs.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\n  The most maintainable approach combines Blogger REST API v3 for content, a small Python CLI or MCP service for controlled AI workflows, and Playwright only where the dashboard is necessary. Start with a test blog, make drafts the default, require approval for public changes and preserve a verified rollback path.\n<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official documentation and further reading<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developers.google.com\/blogger\/docs\/3.0\/reference\" rel=\"noopener\">Google Blogger API v3 reference<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developers.google.com\/blogger\/docs\/3.0\/getting_started\" rel=\"noopener\">Blogger API getting started<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developers.google.com\/blogger\/docs\/3.0\/using\" rel=\"noopener\">Blogger API usage examples<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developers.google.com\/blogger\/docs\/3.0\/reference\/posts\/insert\" rel=\"noopener\">Post insertion and draft parameter<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developers.google.com\/blogger\/docs\/3.0\/reference\/posts\/publish\" rel=\"noopener\">Post publish and scheduling<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developers.google.com\/identity\/protocols\/oauth2\" rel=\"noopener\">Google OAuth 2.0 and refresh token expiration<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developers.google.com\/identity\/protocols\/oauth2\/native-app\" rel=\"noopener\">Desktop OAuth flow<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/support.google.com\/blogger\/answer\/1227173?hl=en\" rel=\"noopener\">Blogger theme help<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/support.google.com\/blogger\/answer\/176245?hl=en\" rel=\"noopener\">Blogger HTML and CSS help<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/support.google.com\/blogger\/thread\/184768091\/how-to-change-the-custom-template-in-my-existing-blog-website?hl=en\" rel=\"noopener\">Blogger community: theme restore workflow<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/support.google.com\/blogger\/answer\/41387?hl=en\" rel=\"noopener\">Blogger backup and import<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/playwright.dev\/python\/docs\/codegen\" rel=\"noopener\">Playwright code generator<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/playwright.dev\/python\/docs\/downloads\" rel=\"noopener\">Playwright downloads and uploads<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/playwright.dev\/python\/docs\/input\" rel=\"noopener\">Playwright input actions<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/code.claude.com\/docs\/en\/mcp\" rel=\"noopener\">Claude Code MCP documentation<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/learn.chatgpt.com\/docs\/extend\/mcp\" rel=\"noopener\">Codex MCP setup<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/modelcontextprotocol\/python-sdk\" rel=\"noopener\">MCP Python SDK<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developers.google.com\/apps-script\/guides\/services\/advanced\" rel=\"noopener\">Google Apps Script advanced services<\/a>\n<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/developers.google.com\/search\/docs\/essentials\/spam-policies\" rel=\"noopener\">Google Search spam policies<\/a>\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Publication notes and verification scope<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\n  Documentation checked November 28, 2026. The API examples were written against the documented interfaces; the core Python snippets were syntax-checked, not executed against an authenticated Blogger account. Browser locators require recording and validation in the reader\u2019s dashboard. The examples are a starting point, not a complete production platform.\n<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Practical tutorial | API publishing, scheduled workflows, multi-blog management and XML theme deployment | November 2026 Featured image (1200 \u00d7 630 px): Blogger automation with API and&#8230; <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[49],"tags":[],"class_list":["post-80347","post","type-post","status-publish","format-standard","hentry","category-general"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/80347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=80347"}],"version-history":[{"count":1,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/80347\/revisions"}],"predecessor-version":[{"id":80351,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/80347\/revisions\/80351"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=80347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=80347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=80347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}