🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How to Get Instagram Stories Using PHP

By Jignesh ParmarUpdated on May 22, 2025 8 min read

Are you an online store that dived into social media marketing? If yes, and if Instagram is your forte, this post is for you.

With social media platforms getting popular each day, businesses have started preferring social media marketing over traditional marketing techniques.

Moreover, Instagram is one of the top social media platforms for businesses to make the most out of it. Majority of the businesses have started selling on Instagram and harnessing its benefits.

The below numbers says it all:

  • More than 25 million businesses are using Instagram for online business – Hootsuite
  • One-third of the most viewed stories are from brands and that 60 percent of total users discover new brands or products on the platform – Instagram
  • In late 2019, Instagram Stories had 500 million monthly active users. – Statista

Leverage Instagram for your E-commerce business because the numbers won’t lie! Reach your intended audience using Instagram.

Unlike posts on Instagram, stories have a more interactive element that online stores can use creatively by mixing in things like videos, swiping, and polls.

Instagram story is the feature of the app allowing users to post photo and video sequences that disappear after 24 hours of being posted.

Now, if you want to go one step ahead and fetch Instagram stories using Php in your online store, you can do so using the method given in this post.

Display the Instagram stories to your store visitors and encourage them to make the purchase in your store.

Steps to Get Instagram Stories Using PHP

In order to get the story, you first need to get the access token and page ID.

Steps to get access token:

get access token step1
  • On click of “Add a New App”, it will open a popup to create an App ID. Select the option “For Everything Else”.
get access token step 02
  • Enter App Display Name and click Create App ID button.
get access token step 03
  • Complete security check and click Submit button and it will redirect you to the Manager app dashboard page.
get access token step 04
  • In Manager app dashboard, go to Setting > Advanced
  • Under the section ‘Business Manager’, select a Business Manager or create a Business Manager then save this setting.
get access token step 05
  • After ‘Save Changes’, click the ‘Configure in Business Manager’ button under the “Business Manager” section. It will redirect to the Business setting dashboard.
get access token step 6
  • Setting Business Account:
    • Create a system user (or reuse an existing one) for this business in Business Settings under Users > System Users tab
    • Add the system used above as someone who acts as an admin for a Page you’re about to generate an access token for. (Add the system user to a selected Page by clicking Add People button under the Accounts > Pages tab.)
    • Add the Assets by clicking the Add Assets tab
    • Select Assets type(Pages and Apps), Assets, and Set Permissions for generating a new token. (here admin has all Permissions)
get access token step 7
  • After adding the assets and people, click “Generate New Token”. Select an app for which you want to generate the token.
get access token step 8
  • Select all the required permission and click “Generate Token”.
get access token step 9
  • After clicking ‘Generate Token’, you will receive a token, copy it.
get access token step 10
get access token step 10
  • Paste the Token here and Debug it.
get access token step 11
  • You can see Token Information like expiry date, validity, origin, scopes, etc.
get access token step 13
  • Enter your Facebook page ID. Follow the steps below to find your Facebook page ID.

Steps to get Facebook Page ID:

  • When you create a new Facebook page, the page ID is given. If you want to find the page ID of an already existing page, visit the page and check the URL. The characters in the URL after the page name is your page ID. For example, the URL is https://www.facebook.com/Test-Business-2387482487989307
  • Here the name of the page is “Test Business” and the digits 2387482487989307 is the page ID.
Get Facebook page ID step1
  • Or, you can get the Page ID from the Page “About” section (only when Logged in to your Facebook) under “More Info”.
Get Facebook page ID step 2

We get the token and Facebook page ID. Now we use both to get instagram_business_account_id.

Steps to get instagram_business_account_id:

In order to get the business_account_id, we need to pass the below URL:

https://graph.facebook.com/v5.0/{fb_page_id}?fields=instagram_business_account&access_token={access_token}

Pass your facebook_page_id and access_token that we’ve got from above steps.

Here we go, it returns “instagram_business_account_id”  as shown in the below image.

Instagram SS URL1

Next, we need to get the media id (story id) using business_account_id and access_token.

https://graph.facebook.com/v10.0/{bussiness_account_id}/stories/?access_token={access_token}

It returns the story_id, as shown below:

Instagram SS URL1

We have all the required ids to get Instagram stories using PHP. Now get the Instagram Story.

Steps to get the Instagram Story:

Pass the below URL:

https://graph.facebook.com/v5.0/{story_id}/?access_token={access_token}&fields=id,media_type,media_url,owner,timestamp,username,thumbnail_url,shortcode,like_count,comments_count,caption

The Instagram story data that has been get will look like below:

get data of story

Now use this story data wherever you want to display the Instagram stories.

It will display up to 24 hours as the lifespan of Instagram stories is 24 hours.

That’s all!

If you don’t want to limit till Instagram stories, but also want to fetch Instagram posts to your Magento 2 store, Meetanshi offers Magento 2 Instagram extension that integrates Magento 2 with Instagram to fetch Instagram images, edit and show them in the front-end to give a look and feel of an amazing Instagram shop in Magento 2 stores.

If you want the same solution for Magento 1, check the Magento Instagram extension.

Use this method and leverage the benefit of marketing through Instagram stories.

Feel free to share the solution with Magento Community via social media.

Thank You.

Jignesh Parmar Full Image
Article byJignesh Parmar

An expert in his field, Jignesh is the team leader at Meetanshi and a certified Magento developer. His passion for Magento has inspired others in the team too. Apart from work, he is a cricket lover.