{"id":1637,"date":"2021-03-04T12:00:52","date_gmt":"2021-03-04T12:00:52","guid":{"rendered":"https:\/\/meetanshi.com\/blog\/get-instagram-stories-using-php\/"},"modified":"2025-07-22T17:48:26","modified_gmt":"2025-07-22T12:18:26","slug":"get-instagram-stories-using-php","status":"publish","type":"post","link":"https:\/\/meetanshi.com\/blog\/get-instagram-stories-using-php\/","title":{"rendered":"How to Get Instagram Stories Using PHP"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Are you an online store that dived into social media marketing? If yes, and if Instagram is your forte, this post is for you.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">With social media platforms getting popular each day, businesses have started preferring social media marketing over traditional marketing techniques.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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&nbsp;<a href=\"https:\/\/meetanshi.com\/blog\/how-to-sell-on-instagram-without-a-website\/\" target=\"_blank\" rel=\"noreferrer noopener\">selling on Instagram<\/a>&nbsp;and harnessing its benefits.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The below numbers says it all:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>More than 25 million businesses&nbsp;<em>are&nbsp;<\/em>using&nbsp;<em>Instagram for online business \u2013&nbsp;<a href=\"https:\/\/blog.hootsuite.com\/how-to-use-instagram-for-business\/\" target=\"_blank\" rel=\"noreferrer noopener\">Hootsuite<\/a><\/em><\/li>\n\n\n\n<li>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 \u2013&nbsp;<a href=\"https:\/\/business.instagram.com\/getting-started?ref=igb_carousel\" target=\"_blank\" rel=\"noreferrer noopener\">Instagram<\/a><\/li>\n\n\n\n<li>In late 2019, Instagram Stories had 500 million monthly active users. \u2013&nbsp;<a href=\"https:\/\/www.statista.com\/statistics\/730315\/instagram-stories-dau\/\" target=\"_blank\" rel=\"noreferrer noopener\">Statista<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/meetanshi.com\/blog\/instagram-for-e-commerce\/\" target=\"_blank\" rel=\"noreferrer noopener\">Leverage Instagram for your E-commerce<\/a>&nbsp;business because the numbers won\u2019t lie! Reach your intended audience using Instagram.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Instagram story is the feature of the app allowing users to post photo and video sequences that disappear after 24 hours of being posted.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">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.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Display the Instagram stories to your store visitors and encourage them to make the purchase in your store.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Get Instagram Stories Using PHP<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In order to get the story, you first need to get the access token and page ID.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Steps to get access token:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Create Facebook app (<a href=\"https:\/\/developers.facebook.com\/docs\/development#register\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/developers.facebook.com\/docs\/development#register<\/a>)<\/li>\n\n\n\n<li>Go to Add a New App (&nbsp;<a href=\"https:\/\/developers.facebook.com\/apps\/\" target=\"_blank\" rel=\"noreferrer noopener\">https:\/\/developers.facebook.com\/apps\/<\/a>)<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token1.png\" alt=\"get access token step1\" class=\"wp-image-13678\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>On click of \u201c<strong>Add a New App<\/strong>\u201d, it will open a popup to create an App ID. Select the option \u201c<strong>For Everything Else\u201d.<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token2-1.png\" alt=\"get access token step 02\" class=\"wp-image-13745\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Enter&nbsp;<strong>App Display Name&nbsp;<\/strong>and click&nbsp;<strong>Create App ID&nbsp;<\/strong>button.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token3-1-1024x541.png\" alt=\"get access token step 03\" class=\"wp-image-13746\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Complete security check and click&nbsp;<strong>Submit<\/strong>&nbsp;button and it will redirect you to the Manager app dashboard page.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token4-1.png\" alt=\"get access token step 04\" class=\"wp-image-13747\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>In Manager app dashboard, go to&nbsp;<strong>Setting &gt; Advanced<\/strong><\/li>\n\n\n\n<li>Under the section \u2018<strong>Business Manager\u2019<\/strong>, select a Business Manager or create a Business Manager then save this setting.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token5-1.png\" alt=\"get access token step 05\" class=\"wp-image-13748\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>After \u2018<strong>Save Changes<\/strong>\u2019, click the \u2018<strong>Configure in Business Manager<\/strong>\u2019 button under the \u201c<strong>Business Manager<\/strong>\u201d section. It will redirect to the&nbsp;<strong>Business setting<\/strong>&nbsp;dashboard.<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token6.png\" alt=\"get access token step 6\" class=\"wp-image-13683\"\/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Setting Business Account<\/strong>:\n<ul class=\"wp-block-list\">\n<li>Create a system user (or reuse an existing one) for this business in Business Settings under&nbsp;<strong>Users<\/strong>&nbsp;&gt;&nbsp;<strong>System Users<\/strong>&nbsp;tab<\/li>\n\n\n\n<li>Add the system used above as someone who acts as an admin for a Page you\u2019re about to generate an access token for. (Add the system user to a selected Page by clicking&nbsp;<strong>Add People<\/strong>&nbsp;button under the&nbsp;<strong>Accounts<\/strong>&nbsp;&gt;&nbsp;<strong>Pages<\/strong>&nbsp;tab.)<\/li>\n\n\n\n<li>Add the Assets by clicking the&nbsp;<strong>Add Assets&nbsp;<\/strong>tab<\/li>\n\n\n\n<li>Select&nbsp;<strong>Assets type<\/strong>(Pages and Apps)<strong>, Assets,&nbsp;<\/strong>and&nbsp;<strong>Set Permissions&nbsp;<\/strong>for generating a new token. (here admin has all Permissions)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token7.png\" alt=\"get access token step 7\" class=\"wp-image-13684\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>After adding the assets and people, click \u201c<strong>Generate New Token<\/strong>\u201d. Select an app for which you want to generate the token.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token8.png\" alt=\"get access token step 8\" class=\"wp-image-13685\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Select all the required permission and click \u201c<strong>Generate Token<\/strong>\u201d.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token9.png\" alt=\"get access token step 9\" class=\"wp-image-13687\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>After clicking \u2018<strong>Generate Token<\/strong>\u2019, you will receive a token, copy it.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token10.png\" alt=\"get access token step 10\" class=\"wp-image-13688\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>After receiving the token, go to&nbsp;<a href=\"https:\/\/developers.facebook.com\/apps\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Facebook for Developers<\/strong><\/a>and click&nbsp;<strong>Tools &gt; Access Token Debugger.<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token11.png\" alt=\"get access token step 10\" class=\"wp-image-13689\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Paste the&nbsp;<strong>Token&nbsp;<\/strong>here and Debug it.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token12.png\" alt=\"get access token step 11\" class=\"wp-image-13690\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>You can see Token Information like expiry date, validity, origin, scopes, etc.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/token-13.png\" alt=\"get access token step 13\" class=\"wp-image-13691\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Enter your Facebook page ID. Follow the steps below to find your Facebook page ID.<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Steps to get Facebook Page ID:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>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&nbsp;https:\/\/www.facebook.com\/Test-Business-2387482487989307<\/li>\n\n\n\n<li>Here the name of the page is \u201cTest Business\u201d and the digits 2387482487989307 is the page ID.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/facebookid-1.png\" alt=\"Get Facebook page ID step1\" class=\"wp-image-13693\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>Or, you can get the Page ID from the Page \u201cAbout\u201d section (only when Logged in to your Facebook) under \u201cMore Info\u201d.<\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/facebookid2.png\" alt=\"Get Facebook page ID step 2\" class=\"wp-image-13694\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">We get the token and Facebook page ID. Now we use both to get instagram_business_account_id.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Steps to get instagram_business_account_id:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In order to get the business_account_id, we need to pass the below URL:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">https:\/\/graph.facebook.com\/v5.0\/{fb_page_id}?fields=instagram_business_account&amp;access_token={access_token}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Pass your&nbsp;<strong>facebook_page_id<\/strong>&nbsp;and&nbsp;<strong>access_token<\/strong>&nbsp;that we\u2019ve got from above steps.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Here we go, it returns \u201cinstagram_business_account_id\u201d&nbsp; as shown in the below image.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/URL1.jpg\" alt=\"Instagram SS URL1\" class=\"wp-image-13697\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Next, we need to get the media id (story id) using business_account_id and access_token.<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">https:\/\/graph.facebook.com\/v10.0\/{bussiness_account_id}\/stories\/?access_token={access_token}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It returns the story_id, as shown below:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/URL2.jpg\" alt=\"Instagram SS URL1\" class=\"wp-image-13699\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">We have all the required ids to get Instagram stories using PHP. Now get the Instagram Story.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Steps to get the Instagram Story:<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Pass the below URL:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">https:\/\/graph.facebook.com\/v5.0\/{story_id}\/?access_token={access_token}&amp;fields=id,media_type,media_url,owner,timestamp,username,thumbnail_url,shortcode,like_count,comments_count,caption<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The Instagram story data that has been get will look like below:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" src=\"https:\/\/meetanshi.com\/blog\/wp-content\/uploads\/2021\/03\/output1.jpg\" alt=\"get data of story\" class=\"wp-image-13701\"\/><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Now use this story data wherever you want to display the Instagram stories.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It will display up to 24 hours as the lifespan of Instagram stories is 24 hours.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">That\u2019s all!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you don\u2019t want to limit till Instagram stories, but also want to fetch Instagram posts to your Magento 2 store, Meetanshi offers&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-2-instagram.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento 2 Instagram<\/a>&nbsp;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 <a href=\"https:\/\/meetanshi.com\/blog\/create-magento-2-instagram-shop\/\">Instagram shop in Magento 2 stores<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you want the same solution for Magento 1, check the&nbsp;<a href=\"https:\/\/meetanshi.com\/magento-instagram.html\" target=\"_blank\" rel=\"noreferrer noopener\">Magento Instagram<\/a>&nbsp;extension.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Use this method and leverage the benefit of marketing through Instagram stories.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Feel free to share the solution with Magento Community via social media.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank You.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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&#8230;<\/p>\n","protected":false},"author":13,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[34],"tags":[],"class_list":["post-1637","post","type-post","status-publish","format-standard","hentry","category-magento"],"acf":[],"_links":{"self":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1637","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/comments?post=1637"}],"version-history":[{"count":3,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1637\/revisions"}],"predecessor-version":[{"id":14463,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/posts\/1637\/revisions\/14463"}],"wp:attachment":[{"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/media?parent=1637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/categories?post=1637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/meetanshi.com\/blog\/wp-json\/wp\/v2\/tags?post=1637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}