RSS to Instagram PHP Bot

Ship RSS to Instagram with a Tiny PHP Bot (No Plugins, No CMS)



Most blogs already syndicate updates through RSS—but Instagram is still a manual grind. In this mini-build, we turn any site (ours wasn’t WordPress) into an auto-publisher: new RSS items → square, readable title cards → posted to an Instagram Professional account via the Instagram Graph API.

The goal is practical and reproducible:

  • Input: your site’s RSS feed.
  • Transform: generate a clean 1080×1080 image with the post title (high contrast, safe margins, custom font).
  • Output: publish to your own Instagram Business/Creator account using the two-step Graph flow (/media → /media_publish).

Why this approach?

  • No third-party schedulers: Great tools exist, but monthly fees add up. We wanted a zero-subscription path we control.
  • Works with any stack: It’s plain PHP with cURL and GD. Drop-in files; no Composer required.
  • Readable thumbnails: Instead of reusing wide (1200×630) OG images that shrink poorly in the grid, we render a square title card that stays legible on mobile.

What we built (at a glance)

  • rss_to_instagram.php — polls your RSS, de-dupes posts, creates a media container, then publishes.
  • iggen.php — a tiny image endpoint that renders title-only square cards (configurable padding, font, colors). Returns JPEG (IG requirement).
  • Optional helpers used during setup (not required in production): OAuth login to get a user token, exchange for a page token, quick “test publish” scripts, and small diagnostics.

Requirements (the non-negotiables)

  • Instagram Professional account (Business or Creator) linked to a Facebook Page.
  • A Facebook App in Development mode, with you as Admin/Tester.
  • Permissions requested at login: instagram_basicpages_show_listpages_read_engagement, and instagram_content_publish.
  • Use a Page Access Token when publishing (user tokens won’t publish).

Security & housekeeping

  • Never commit secrets. In the sample code we’ll publish, all tokens/IDs are redacted and loaded from environment variables or a local config file ignored by Git.
  • Add a simple file lock so your cron job can’t double-run.
  • Consider a tiny de-dup store (file or DB) keyed by RSS guid to avoid accidental reposts.

What you’ll learn

  1. How to grab a long-lived user token, derive a Page Access Token, and publish safely.
  2. How to generate consistently readable IG images with GD (font selection, padding, fallback).
  3. How to harden a quick script for real-world use (timeouts, error logging, limits).

In the next section, I’ll share the redacted code snippets and a step-by-step setup. If you can run PHP and edit a couple of files, you can ship this in under an hour—and finally let Instagram take care of itself.

Prerequisites

  • Instagram Professional (Business or Creator) account linked to a Facebook Page.

  • Facebook App in Development mode. You (the publisher) are Admin/Tester.

  • When logging in to get tokens, request these scopes:
    instagram_basicpages_show_listpages_read_engagementinstagram_content_publish.

  • You will publish with a Page Access Token (not a user token).


RSS to Instagram PHP Bot: Build a tiny PHP bot that turns your RSS feed into square title cards and auto-posts to your Instagram Professional account via Graph API.

Yorumlar

Bu blogdaki popüler yayınlar

Öğrenciler İçin Verimli Ders Çalışma Yöntemleri

Bilgi Paylaşımı Neden Önemli?

Günlük Hayatta Merak Ettiklerimiz