{"id":246,"date":"2019-06-29T15:04:11","date_gmt":"2019-06-29T15:04:11","guid":{"rendered":"https:\/\/blog.staginginstance.com\/?p=246"},"modified":"2019-07-01T02:23:21","modified_gmt":"2019-07-01T02:23:21","slug":"integration-connect-manage-instagram-accounts-via-facebook-graph-api","status":"publish","type":"post","link":"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/","title":{"rendered":"Integration: Connect &#038; Manage Instagram Accounts via Facebook Graph API"},"content":{"rendered":"\n<p>I recently had a chance to integrate Facebook Graph API to connect Instagram (IG) accounts in order to manage IG accounts. For Business managers it is very important that they have tools, proper interface to manage the IG accounts easily. <\/p>\n\n\n\n<p>So before we dive in, please understand there are some limitations to use the API, you will have to go through the review process and will have to verify your business by providing proper documentation. Official API for IG no longer accepts app requests for review. So Facebook Graph API is the only way to go with now. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"limitations\"><strong>Limitations<\/strong><\/h3>\n\n\n\n<ul><li>The API cannot be used to access non-Business or non-Creator Instagram accounts. If you are building apps for non-Business or non-Creator Instagram users, use the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/www.instagram.com\/developer\/?fbclid=IwAR2iJQD5QzYXcVb27aPwMD0S2Tk_Um1uCIRvbLszxgeUtbnXQORL2sRyATI\" target=\"_blank\">Instagram Platform API<\/a>&nbsp;instead.<\/li><li>Currently,&nbsp;<a href=\"https:\/\/developers.facebook.com\/docs\/instagram-api\/guides\/business-discovery\">Business Discovery<\/a>&nbsp;only returns data about Instagram Business Users.<\/li><li><a href=\"https:\/\/developers.facebook.com\/docs\/instagram-api\/guides\/content-publishing\">Content Publishing<\/a>&nbsp;can only be used on behalf of Instagram Business Users.<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Permissions<\/strong><\/h3>\n\n\n\n<p> There are multiple permissions to look at based on use case. I will be using <strong>instagram_basic <\/strong>to get metadata.  Here are all the permissions graph API offers:<\/p>\n\n\n\n<ul><li><a href=\"https:\/\/developers.facebook.com\/docs\/apps\/review\/login-permissions#instagram-basic\"><code>instagram_basic<\/code><\/a><\/li><li><a href=\"https:\/\/developers.facebook.com\/docs\/apps\/review\/login-permissions#instagram-content-publish\"><code>instagram_content_publish<\/code><\/a><\/li><li><a href=\"https:\/\/developers.facebook.com\/docs\/apps\/review\/login-permissions#instagram-manage-comments\"><code>instagram_manage_comments<\/code><\/a><\/li><li><a href=\"https:\/\/developers.facebook.com\/docs\/apps\/review\/login-permissions#instagram-manage-insights\"><code>instagram_manage_insights<\/code><\/a><\/li><li><a href=\"https:\/\/developers.facebook.com\/docs\/apps\/review\/login-permissions#manage-pages\"><code>manage_pages<\/code><\/a>&nbsp;or&nbsp;<a href=\"https:\/\/developers.facebook.com\/docs\/apps\/review\/login-permissions#pages-show-list\"><code>pages_show_list<\/code><\/a><\/li><li><a href=\"https:\/\/developers.facebook.com\/docs\/apps\/review\/feature#reference-INSTAGRAM_PUBLIC_CONTENT_ACCESS\">Instagram Public Content Access<\/a><\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Getting Started<\/strong><\/h3>\n\n\n\n<p>You will need access to the following:<\/p>\n\n\n\n<ul><li>An&nbsp;<a href=\"https:\/\/help.instagram.com\/502981923235522?fbclid=IwAR0-Whw9Np3jewGtNrbQnGoUiZB8HSrJuidy8FXTnXmH5hwRlFc2XJiVkCI\" target=\"_blank\" rel=\"noreferrer noopener\">Instagram Business Account<\/a>&nbsp;or&nbsp;<a href=\"https:\/\/help.instagram.com\/1158274571010880?fbclid=IwAR3NVT6hLXzuebstmMCF7Ymlk2VZVysfplxPaWD2EoIf9VIS5HO3fAofmmQ\" target=\"_blank\" rel=\"noreferrer noopener\">Instagram Creator Account<\/a><\/li><li>A&nbsp;<a href=\"https:\/\/developers.facebook.com\/docs\/instagram-api\/overview#pages\">Facebook Page connected to that account<\/a><\/li><li>A Facebook Developer account that can perform&nbsp;<a href=\"https:\/\/developers.facebook.com\/docs\/instagram-api\/overview#tasks\">Tasks on that Page<\/a><\/li><li>A&nbsp;<a href=\"https:\/\/developers.facebook.com\/docs\/apps#register\">registered Facebook App<\/a>&nbsp;with&nbsp;<strong>Basic<\/strong>&nbsp;settings configured<\/li><\/ul>\n\n\n\n<p>Now right to the steps to integrate Graph API.<\/p>\n\n\n\n<ol><li>Setup a basic project, for this article a PHP project.<\/li><li>Now Install Official Facebook SDK. I created everything in PHP so link to Facebook&#8217;s PHP SDK is  <a href=\"https:\/\/github.com\/facebook\/php-graph-sdk\">https:\/\/github.com\/facebook\/php-graph-sdk<\/a>. You can use composer to install it.<\/li><li>Once installed, download following wrapper I have created to make it easier to make calls to graph API and handle request and response. Once downloaded, include it in the project. Make sure to fill in app ID, app secret and redirect url in it. <a href=\"https:\/\/gist.github.com\/abhij89\/f409b4ae91bfc228cb66c78a1b969131\">https:\/\/gist.github.com\/abhij89\/f409b4ae91bfc228cb66c78a1b969131<\/a><\/li><li>Now create a file, and put following content in it: <br><code><strong>&lt;?php <br> include('InstagramGraphLogin.php'); <br> $instagramLogin = new InstagramSocial(); <br> $instagramLoginUrl = $instagramLogin-&gt;getLoginUrl(); \/\/ include the wrapper<br>?&gt;<br> &lt;a href=\"&lt;?php echo $instagramLoginUrl; ?&gt;\" class=\"btn btn-social btn-instagram\"&gt;Connect Instagram&lt;\/a&gt; &lt;!-- Login Authentication URL for Facebook --&gt;<\/strong><\/code><br><br>This will put a simple button which will take you to Facebook for login authentication and asking you to grant permissions to our app to manage Instagram Accounts. <br><strong>Note<\/strong>: Instagram account should be connected to one of the Facebook page for this to work. Go to your Facebook page settings, click on Instagram from sidebar and connect IG account. Following image shows how:<br><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"639\" src=\"https:\/\/blog.staginginstance.com\/wp-content\/uploads\/2019\/06\/connectInstagram-1024x639.png\" alt=\"\" class=\"wp-image-253\" srcset=\"https:\/\/geekabhi.com\/blog\/wp-content\/uploads\/2019\/06\/connectInstagram-1024x639.png 1024w, https:\/\/geekabhi.com\/blog\/wp-content\/uploads\/2019\/06\/connectInstagram-300x187.png 300w, https:\/\/geekabhi.com\/blog\/wp-content\/uploads\/2019\/06\/connectInstagram-768x479.png 768w, https:\/\/geekabhi.com\/blog\/wp-content\/uploads\/2019\/06\/connectInstagram.png 1419w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/li><li>Create another file which will handle the response once user authenticates our app. Put following content in the same: <br> <code><strong>&lt;?php <br> include('InstagramGraphLogin.php'); <br> $instagramLogin = new InstagramSocial();<br> $connectedAccountsData = $instagramSocial-&gt;getUserInfo(); \/\/ returns basic metadata for connected IG accounts<br><br>echo \"&lt;pre&gt;\"; print_r(  $connectedAccountsData );<br>\/\/ Do something with the data<\/strong><\/code><br><\/li><li>You&#8217;re done.<\/li><\/ol>\n\n\n\n<p>Easy enough. <br><br>Here is a official documentation from Facebook:  <a href=\"https:\/\/developers.facebook.com\/docs\/instagram-api\/getting-started\">https:\/\/developers.facebook.com\/docs\/instagram-api\/getting-started<\/a> <\/p>\n\n\n\n<p>Issue I ran in while working it out:  <a href=\"https:\/\/github.com\/facebook\/php-graph-sdk\/issues\/1126\">https:\/\/github.com\/facebook\/php-graph-sdk\/issues\/1126<\/a> <\/p>\n\n\n\n<p>Author&#8217;s GitHub Profile: <a href=\"https:\/\/github.com\/abhij89\">https:\/\/github.com\/abhij89<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I recently had a chance to integrate Facebook Graph API to connect Instagram (IG) accounts in order to manage IG accounts. For Business managers it is very important that they have tools, proper interface to manage the IG accounts easily. So before we dive in, please understand there are some limitations to use the API,&hellip; <a class=\"more-link\" href=\"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/\">Continue reading <span class=\"screen-reader-text\">Integration: Connect &#038; Manage Instagram Accounts via Facebook Graph API<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,27],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v21.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Integration: Connect &amp; Manage Instagram Accounts via Facebook Graph API - Learner at life<\/title>\n<meta name=\"description\" content=\"Tutorial explaining how to Connect &amp; Manage Instagram Accounts via Facebook Graph API. This article explains how to integrate graph api to manage Instagram accounts for any user.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Integration: Connect &amp; Manage Instagram Accounts via Facebook Graph API\" \/>\n<meta property=\"og:description\" content=\"Connect &amp; Manage Instagram Accounts via Facebook Graph API. This article explains how to integrate graph api to manage Instagram accounts for any user.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/\" \/>\n<meta property=\"og:site_name\" content=\"Learner at life\" \/>\n<meta property=\"article:publisher\" content=\"http:\/\/abhij89\" \/>\n<meta property=\"article:published_time\" content=\"2019-06-29T15:04:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-07-01T02:23:21+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/geekabhi.com\/blog\/wp-content\/uploads\/2019\/06\/connectInstagram.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1419\" \/>\n\t<meta property=\"og:image:height\" content=\"885\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abhishek Jain\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Integration: Connect &amp; Manage Instagram Accounts via Facebook Graph API\" \/>\n<meta name=\"twitter:description\" content=\"Connect &amp; Manage Instagram Accounts via Facebook Graph API. This article explains how to integrate graph api to manage Instagram accounts for any user.\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/geekabhi.com\/blog\/wp-content\/uploads\/2019\/06\/connectInstagram.png\" \/>\n<meta name=\"twitter:creator\" content=\"@abhij89\" \/>\n<meta name=\"twitter:site\" content=\"@abhij89\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhishek Jain\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/\",\"url\":\"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/\",\"name\":\"Integration: Connect & Manage Instagram Accounts via Facebook Graph API - Learner at life\",\"isPartOf\":{\"@id\":\"https:\/\/geekabhi.com\/blog\/#website\"},\"datePublished\":\"2019-06-29T15:04:11+00:00\",\"dateModified\":\"2019-07-01T02:23:21+00:00\",\"author\":{\"@id\":\"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/75cf5ee8cc7d8c1a9ba81628bb57443e\"},\"description\":\"Tutorial explaining how to Connect & Manage Instagram Accounts via Facebook Graph API. This article explains how to integrate graph api to manage Instagram accounts for any user.\",\"breadcrumb\":{\"@id\":\"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/geekabhi.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Integration: Connect &#038; Manage Instagram Accounts via Facebook Graph API\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/geekabhi.com\/blog\/#website\",\"url\":\"https:\/\/geekabhi.com\/blog\/\",\"name\":\"Learner at life\",\"description\":\"Blog to help you learn stuff\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/geekabhi.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/75cf5ee8cc7d8c1a9ba81628bb57443e\",\"name\":\"Abhishek Jain\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/85387a40fe2c6954082743d1a8aa6c0f?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/85387a40fe2c6954082743d1a8aa6c0f?s=96&d=mm&r=g\",\"caption\":\"Abhishek Jain\"},\"description\":\"Techie with 10+ years of experience and counting.\",\"sameAs\":[\"http:\/\/www.geekabhi.com\",\"https:\/\/twitter.com\/abhij89\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Integration: Connect & Manage Instagram Accounts via Facebook Graph API - Learner at life","description":"Tutorial explaining how to Connect & Manage Instagram Accounts via Facebook Graph API. This article explains how to integrate graph api to manage Instagram accounts for any user.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/","og_locale":"en_US","og_type":"article","og_title":"Integration: Connect & Manage Instagram Accounts via Facebook Graph API","og_description":"Connect & Manage Instagram Accounts via Facebook Graph API. This article explains how to integrate graph api to manage Instagram accounts for any user.","og_url":"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/","og_site_name":"Learner at life","article_publisher":"http:\/\/abhij89","article_published_time":"2019-06-29T15:04:11+00:00","article_modified_time":"2019-07-01T02:23:21+00:00","og_image":[{"width":1419,"height":885,"url":"https:\/\/geekabhi.com\/blog\/wp-content\/uploads\/2019\/06\/connectInstagram.png","type":"image\/png"}],"author":"Abhishek Jain","twitter_card":"summary_large_image","twitter_title":"Integration: Connect & Manage Instagram Accounts via Facebook Graph API","twitter_description":"Connect & Manage Instagram Accounts via Facebook Graph API. This article explains how to integrate graph api to manage Instagram accounts for any user.","twitter_image":"https:\/\/geekabhi.com\/blog\/wp-content\/uploads\/2019\/06\/connectInstagram.png","twitter_creator":"@abhij89","twitter_site":"@abhij89","twitter_misc":{"Written by":"Abhishek Jain","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/","url":"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/","name":"Integration: Connect & Manage Instagram Accounts via Facebook Graph API - Learner at life","isPartOf":{"@id":"https:\/\/geekabhi.com\/blog\/#website"},"datePublished":"2019-06-29T15:04:11+00:00","dateModified":"2019-07-01T02:23:21+00:00","author":{"@id":"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/75cf5ee8cc7d8c1a9ba81628bb57443e"},"description":"Tutorial explaining how to Connect & Manage Instagram Accounts via Facebook Graph API. This article explains how to integrate graph api to manage Instagram accounts for any user.","breadcrumb":{"@id":"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/geekabhi.com\/blog\/integration-connect-manage-instagram-accounts-via-facebook-graph-api\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/geekabhi.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Integration: Connect &#038; Manage Instagram Accounts via Facebook Graph API"}]},{"@type":"WebSite","@id":"https:\/\/geekabhi.com\/blog\/#website","url":"https:\/\/geekabhi.com\/blog\/","name":"Learner at life","description":"Blog to help you learn stuff","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/geekabhi.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/75cf5ee8cc7d8c1a9ba81628bb57443e","name":"Abhishek Jain","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/geekabhi.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/85387a40fe2c6954082743d1a8aa6c0f?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/85387a40fe2c6954082743d1a8aa6c0f?s=96&d=mm&r=g","caption":"Abhishek Jain"},"description":"Techie with 10+ years of experience and counting.","sameAs":["http:\/\/www.geekabhi.com","https:\/\/twitter.com\/abhij89"]}]}},"_links":{"self":[{"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/posts\/246"}],"collection":[{"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/comments?post=246"}],"version-history":[{"count":15,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/posts\/246\/revisions"}],"predecessor-version":[{"id":262,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/posts\/246\/revisions\/262"}],"wp:attachment":[{"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/media?parent=246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/categories?post=246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekabhi.com\/blog\/wp-json\/wp\/v2\/tags?post=246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}