Instagram Graph API integration with website

Our company is engaged in the development, support and maintenance of sites of any complexity. From simple one-page sites to large-scale cluster systems built on micro services. Experience of developers is confirmed by certificates from vendors.
Development and maintenance of all types of websites:
Informational websites or web applications
Business card websites, landing pages, corporate websites, online catalogs, quizzes, promo websites, blogs, news resources, informational portals, forums, aggregators
E-commerce websites or web applications
Online stores, B2B portals, marketplaces, online exchanges, cashback websites, exchanges, dropshipping platforms, product parsers
Business process management web applications
CRM systems, ERP systems, corporate portals, production management systems, information parsers
Electronic service websites or web applications
Classified ads platforms, online schools, online cinemas, website builders, portals for electronic services, video hosting platforms, thematic portals

These are just some of the technical types of websites we work with, and each of them can have its own specific features and functionality, as well as be customized to meet the specific needs and goals of the client.

Our competencies:
Development stages
Latest works
  • image_web-applications_feedme_466_0.webp
    Development of a web application for FEEDME
    1161
  • image_ecommerce_furnoro_435_0.webp
    Development of an online store for the company FURNORO
    1041
  • image_crm_enviok_479_0.webp
    Development of a web application for Enviok
    822
  • image_crm_chasseurs_493_0.webp
    CRM development for Chasseurs
    847
  • image_website-sbh_0.png
    Website development for SBH Partners
    999
  • image_website-_0.png
    Website development for Red Pear
    451

Instagram Graph API Integration with Website

Instagram Graph API allows displaying business account publications on your website, retrieving statistics, and managing comments. Available only for professional accounts (Business or Creator).

Requirements

  • Instagram Business or Creator account
  • Facebook Page linked to your account
  • Application in Meta Developer Portal with instagram_basic, pages_show_list permissions

Obtaining Access Token

// Exchange short-lived token for long-lived token (60 days)
$resp = Http::get('https://graph.facebook.com/oauth/access_token', [
    'grant_type'        => 'fb_exchange_token',
    'client_id'         => config('services.instagram.app_id'),
    'client_secret'     => config('services.instagram.app_secret'),
    'fb_exchange_token' => $shortLivedToken,
]);

$longLivedToken = $resp->json('access_token');

Long-lived tokens must be refreshed every 60 days. Implement this as a scheduled task.

Retrieving Publications

class InstagramService
{
    public function getPosts(int $limit = 12): array
    {
        $resp = Http::get("https://graph.instagram.com/me/media", [
            'fields'       => 'id,caption,media_type,media_url,thumbnail_url,permalink,timestamp',
            'limit'        => $limit,
            'access_token' => $this->accessToken,
        ]);

        return collect($resp->json('data'))
            ->filter(fn($p) => in_array($p['media_type'], ['IMAGE', 'CAROUSEL_ALBUM']))
            ->map(fn($p) => [
                'id'        => $p['id'],
                'caption'   => $this->truncateCaption($p['caption'] ?? '', 150),
                'image_url' => $p['media_url'],
                'url'       => $p['permalink'],
                'date'      => $p['timestamp'],
            ])
            ->values()
            ->all();
    }
}

"Instagram Feed" Widget on Website

function InstagramFeed({ posts }: { posts: Post[] }) {
  return (
    <div className="grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-2">
      {posts.map(post => (
        <a key={post.id} href={post.url} target="_blank" rel="noopener"
           className="aspect-square overflow-hidden rounded group">
          <img
            src={post.image_url}
            alt={post.caption}
            loading="lazy"
            className="w-full h-full object-cover transition-transform group-hover:scale-105"
          />
        </a>
      ))}
    </div>
  );
}

API Limitations

  • Media files (image_url) are available via Instagram CDN links with limited lifetime (~7 days). Cache must be refreshed periodically
  • Rate limit: 200 requests/hour per token
  • Reels require separate instagram_content_publish permission

Timeline

Displaying publications feed with caching: 2–3 business days.