App Verification Details https://levelup.gitconnected.com/automating-instagram-posts-with-python-and-instagram-graph-api-374f084b9f2b To Get Started go to the developers page: https://developers.facebook.com/tools/explorer/ Crime-Watch App ID: 477626176399600 Type: Business App Secret: 669e5a844664d716dedd7948073c352f Client Token: 08bd42fd7776a14edb06ca8b6d6f16e8 Access Token (short life 60 minutes): EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD Run the following command to get a 60 day access tokens curl -i -X GET "https://graph.facebook.com/{graph-api-version}/oauth/access_token? grant_type=fb_exchange_token& client_id={app-id}& client_secret={app-secret}& fb_exchange_token={your-access-token}" Run this command to get long life Access Token curl -i -X GET "https://graph.facebook.com/v15.0/oauth/access_token?grant_type=fb_exchange_token&client_id=477626176399600&client_secret=669e5a844664d716dedd7948073c352f&fb_exchange_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" HTTP/1.1 200 OK Content-Type: application/json; charset=UTF-8 facebook-api-version: v15.0 Access-Control-Allow-Origin: * Strict-Transport-Security: max-age=15552000; preload Pragma: no-cache Cache-Control: private, no-cache, no-store, must-revalidate Expires: Sat, 01 Jan 2000 00:00:00 GMT x-fb-request-id: AkVRBQLlH3wo04VrVH0YY98 x-fb-trace-id: FxVOkVg+IfP x-fb-rev: 1006267284 X-FB-Debug: CRszCh2yW4q7ZkWf2Fm91H9xiFFe1PLHA/MigCRlrVJkbV5Cv7k0NESAAsTMx8bNxh0wCU1/IZWlXLs6+8hKbg== Date: Sun, 25 Sep 2022 17:36:45 GMT Alt-Svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400 Connection: keep-alive Content-Length: 239 {"access_token":"EAAGyZAgKUaPABAOsjLPrNHQBqWp0FYdwucx836Dx86HKjpKD6ARlZAEQc9b2aNnFZAkryjHwNgiAkkzlSnRYMWElcvVBH35p0uZBU93oWzOtTDZCP3eJRwvruNyJbSbL4EyXlLwFkCTaOZCZABQuN0dQ9NGqlufnWbeUJYabCTwxAvWQmMw0y1t5MLZAyWo8Jy8ZD","token_type":"bearer"} {"access_token":"EAAGyZAgKUaPABABwwWIQxcO8ByCKQj3SAbzUxLHXJVN2WwnOrdESVQuifXvhF8H2WYXS17S96uKiN6ZAUlGZBm1D5bqmtKvRnSt7s9aJnZAZBt99xJSNo3jZAzfj32p0CT1aHyfhaXXSIZCVllolBa2yyiLWMatD5tXQxTPRQz6R9hSX5dfXloHNDejhbyQWXwZD","token_type":"bearer"} Access Token (long life 60 days): as of 09-25-2022 expires 11-24-2022 EAAGyZAgKUaPABAOsjLPrNHQBqWp0FYdwucx836Dx86HKjpKD6ARlZAEQc9b2aNnFZAkryjHwNgiAkkzlSnRYMWElcvVBH35p0uZBU93oWzOtTDZCP3eJRwvruNyJbSbL4EyXlLwFkCTaOZCZABQuN0dQ9NGqlufnWbeUJYabCTwxAvWQmMw0y1t5MLZAyWo8Jy8ZD Access Token (long life 60 days): as of 10-10-2022 expires 12-09-2022 EAAGyZAgKUaPABABwwWIQxcO8ByCKQj3SAbzUxLHXJVN2WwnOrdESVQuifXvhF8H2WYXS17S96uKiN6ZAUlGZBm1D5bqmtKvRnSt7s9aJnZAZBt99xJSNo3jZAzfj32p0CT1aHyfhaXXSIZCVllolBa2yyiLWMatD5tXQxTPRQz6R9hSX5dfXloHNDejhbyQWXwZD https://business.facebook.com/settings/instagram-account-v2s/17841455644650339?business_id=201120095674531 Run this command to get the instagram business page User ID curl -i -X GET \ "https://graph.facebook.com/v10.0/{facebook_page_id}?fields=instagram_business_account&access_token={access-token}" curl -i -X GET "https://graph.facebook.com/v10.0/106077074233723?fields=instagram_business_account&access_token=EAAGyZAgKUaPABAOsjLPrNHQBqWp0FYdwucx836Dx86HKjpKD6ARlZAEQc9b2aNnFZAkryjHwNgiAkkzlSnRYMWElcvVBH35p0uZBU93oWzOtTDZCP3eJRwvruNyJbSbL4EyXlLwFkCTaOZCZABQuN0dQ9NGqlufnWbeUJYabCTwxAvWQmMw0y1t5MLZAyWo8Jy8ZD" HTTP/1.1 200 OK ETag: "10a1b3f4e376677b0c7101ba35ff0911bfe45dc1" Content-Type: application/json; charset=UTF-8 Vary: Origin x-business-use-case-usage: {"17841426276423966":[{"type":"instagram","call_count":1,"total_cputime":1,"total_time":1,"estimated_time_to_regain_access":0}],"106077074233723":[{"type":"pages","call_count":1,"total_cputime":1,"total_time":1,"estimated_time_to_regain_access":0}]} x-fb-rlafr: 0 Access-Control-Allow-Origin: * facebook-api-version: v12.0 Strict-Transport-Security: max-age=15552000; preload Pragma: no-cache Cache-Control: private, no-cache, no-store, must-revalidate Expires: Sat, 01 Jan 2000 00:00:00 GMT x-fb-request-id: As0CMxH_QGeV5lumpPt_2Pj x-fb-trace-id: EhjSdMl1RqG x-fb-rev: 1006267284 X-FB-Debug: 6/qRXcLXCk/jfAb1DoUT+d2av84fADnxS1ZYUP4THJrmqtHOXrJJ3Oo2KDuPX+qjKWZ0UH/3E3EJQzlc9zrkwQ== Date: Sun, 25 Sep 2022 17:39:22 GMT Priority: u=3,i Alt-Svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400 Connection: keep-alive Content-Length: 80 {"instagram_business_account":{"id":"17841426276423966"},"id":"106077074233723"} Dallas- {"instagram_business_account":{"id":"17841433316570474"},"id":"111747460486566"} Chicago- {"instagram_business_account":{"id":"17841447985520404"},"id":"103524615269981"} Atlanta- {"instagram_business_account":{"id":"17841455255976741"},"id":"347260609845549"} Monroe {"instagram_business_account":{"id":"17841455717131314"},"id":"347260609845549"} Houston {"instagram_business_account":{"id":"17841401875127956"},"id":"347260609845549"} stagefrightmvp {"instagram_business_account":{"id":"17841448935451364"},"id":"171614886261218"} Detroit- link to Kim's CrimeInTheD facebook & instagram pages {"instagram_business_account":{"id":"17841453173754502"},"id":"171614886261218"} link to Tim's CrimeInTheD facebook page {"instagram_business_account":{"id":"17841455644650339"},"id":"100818736157188"} MetroCrimeDaily- @metrocrimedaily Owned by: MetroCrimeDaily ID: 17841455644650339 Metrocrimedaily Owned by: MetroCrimeDaily ID: 100818736157188 MetroCrimeDaily Business Account ID: 201120095674531 facebook pageID - CrimeWatchDallas : 106077074233723 Instagram BID: 17841426276423966 facebook pageID - CrimeWatchChicago: 111747460486566 Instagram BID: 17841433316570474 facebook pageID - CrimeWatchAtlanta: 103524615269981 Instagram BID: 17841447985520404 facebook pageID - CrimeWatchDetroit: 171614886261218 Instagram BID: 17841453173754502 facebook pageID - CrimeWatchMonroe : 347260609845549 Instagram BID: 17841455255976741 facebook pageID - CrimeWatchHouston: 347260609845549 Instagram BID: 17841455717131314 facebook pageID - stagefrightmvp : 347260609845549 Instagram BID: 17841401875127956 facebook pageID - MetroCrimeDaily : 100818736157188 Instagram BID: 17841455644650339 Publish a post to your instagram page using Instagram Graph API Posts are sent to instagram in a two step process: (1) You create a container with the image, instagram returns you a creation id, (2) you publish the creation id to send the post to instagram. NOTE: All requests need your user access token (preferably the long life token). the next curl command will retrieve a IG creation_id value that is used to publish the image and caption to IG curl -i -X POST https://graph.facebook.com/v10.0/{ig_user_id}/media?image_url={public_http_path_to_image}&caption={url_encoded_caption}&access_token={user_access_token} What you need for this request is: IG user ID from section above = 17841426276423966 Dallas IG user ID from section above = 17841433316570474 Chicago IG user ID from section above = 17841447985520404 Atlanta IG user ID from section above = 17841453173754502 Detroit IG user ID from section above = 17841455255976741 Monroe IG user ID from section above = 17841455717131314 Houston IG user ID from section above = 17841455644650339 MetroCrimeDaily IG user ID from section above = 17841401875127956 stagefrightmvp User access token: EAAGyZAgKUaPABALSGoC4ZAiyfdR7dTt2JjcMzx8iZBZA0LHeIENbrLxC35UAlE003T5yGfy2m8kCMPxzGc0i6ddiAXAvBZAHNYu6KQUE86zrNCO2MsB0C19YdHs5e6AWPM2ZBU1C1T8hPkXYa5LDMT2DixbzSKLrokqLw3SjzZBIpGxLxogrGYTqICW0xNE2ZCQZD Path to image you want to post (ideally square image for IG and the path must be publicly accesible, like http or https server) file://localhost/E$/INSTAGRAM-AUTOMATION\IG-image1.jpg URL encoded caption 'this is a test caption that was posted to instagram along with an image' Get creation_id ... for Dallas, Chicago, Atlanta -------- curl -i -X POST "https://graph.facebook.com/v15.0/17841426276423966/media?image_url=http://www.metrocrimedaily.com/instagram-dallas/IG-Image1.jpg&access_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" --data-urlencode "caption=line1 this is a test to see what encoding looks like for a single quote ' and a double quote and a Question mark ? and a slash / and yes a < and a > and an asterisk * and up carrot ^ and what about a % and a $ sign and a # sign and an at @ and what if we add some numbers like 100 200 300 4 5 6 7 8 9 10 ok this is enough line2 line3 line4 ddafafaf afasdfaf line5 here here line6 line7 is a test line9 Line10 is the last line in the file for now ... let's see what happens next EOF" DALLAS creation_id ... using ig_user_id: 17841426276423966 { "id": "17872890377766395" } ---------- "https://graph.facebook.com/v15.0/17841433316570474/media?image_url=http://www.metrocrimedaily.com/instagram-dallas/IG-Image1.jpg&access_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" --data-urlencode "caption=line1 this is a test to see what encoding looks like for a single quote ' and a double quote and a Question mark ? and a slash / and yes a < and a > and an asterisk * and up carrot ^ and what about a % and a $ sign and a # sign and an at @ and what if we add some numbers like 100 200 300 4 5 6 7 8 9 10 ok this is enough line2 line3 line4 ddafafaf afasdfaf line5 here here line6 line7 is a test line9 Line10 is the last line in the file for now ... let's see what happens next EOF" CHICAGO creation_id ... using ig_user_id: 17841433316570474 { "id": "17961669166865281" } ----------- "https://graph.facebook.com/v15.0/17841447985520404/media?image_url=http://www.metrocrimedaily.com/instagram-dallas/IG-Image1.jpg&access_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" --data-urlencode "caption=line1 this is a test to see what encoding looks like for a single quote ' and a double quote and a Question mark ? and a slash / and yes a < and a > and an asterisk * and up carrot ^ and what about a % and a $ sign and a # sign and an at @ and what if we add some numbers like 100 200 300 4 5 6 7 8 9 10 ok this is enough line2 line3 line4 ddafafaf afasdfaf line5 here here line6 line7 is a test line9 Line10 is the last line in the file for now ... let's see what happens next EOF" ATLANTA creation_id ... using ig_user_id: 17841447985520404 { "id": "17940328397199853" } ---------- Publish post to my instagram accounts - DALLAS, CHICAGO, Atlanta pages using ig_user_id and creation_id from above DALLAS curl -i -X POST "https://graph.facebook.com/v15.0/17841426276423966/media_publish?creation_id=17872890377766395&access_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" CHICAGO curl -i -X POST "https://graph.facebook.com/v15.0/17841433316570474/media_publish?creation_id=17961669166865281&access_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" ATLANTA curl -i -X POST "https://graph.facebook.com/v15.0/17841447985520404/media_publish?creation_id=17940328397199853&access_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" DETROIT curl -i -X POST "https://graph.facebook.com/v15.0/17841453173754502/media_publish?creation_id=17940328397199853&access_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" to see the quota usage for a page execute the following command for MONROE curl -i -X GET "https://graph.facebook.com/v15.0/17841455255976741/content_publishing_limit?access_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" HTTP/1.1 200 OK ETag: "e6a70e9497277ca7906aac7247afb21a97ac8faf" Content-Type: application/json; charset=UTF-8 Vary: Origin x-business-use-case-usage: {"17841455255976741":[{"type":"instagram","call_count":1,"total_cputime":1,"total_time":1,"estimated_time_to_regain_access":0}]} x-fb-rlafr: 0 Access-Control-Allow-Origin: * facebook-api-version: v15.0 Strict-Transport-Security: max-age=15552000; preload Pragma: no-cache Cache-Control: private, no-cache, no-store, must-revalidate Expires: Sat, 01 Jan 2000 00:00:00 GMT x-fb-request-id: A5vEGeHmAkIYOO_C8482TM7 x-fb-trace-id: EtD80tUAvMK x-fb-rev: 1006310789 X-FB-Debug: lwDI4hrsCk0OMmobFQrieBD8zgn6+XQ15s5CCc6+MSRGEUm1rnfCTEFnW/E9DhkWjg1pqVPI0NfML2D+b3D7IA== Date: Mon, 03 Oct 2022 22:03:05 GMT Priority: u=3,i Alt-Svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400 Connection: keep-alive Content-Length: 29 {"data":[{"quota_usage":17}]} rem quota-usage for MetroCrimeDaily curl -i -X GET "https://graph.facebook.com/v15.0/17841455644650339/content_publishing_limit?access_token=EAAGyZAgKUaPABABohUG7maqQVFZACwMTZBgCOLyLzuDs62BEQmTBjTc55i4bxzY0rF9jaObgLYS36jET7i4o7NaZCCwniqvXZC3rcsFIWm0DFJi1aSuc9XKJdQZBr2wH5ZAkdTEbfCco63Ev6pLyuuY9INxNsPGQRkfZBdPBem6KomHK7XksFwcf54Ir1bZAVwxURzNPTZCjYdTQZDZD" Created CrimeWatchUSA FB and IG accounts FB -> Crime-Watch-USA IG -> CrimeWatchUSA FB Page Info ------------------- Crime-Watch-USA Owned by: CrimeWatchUSA ID: 114163234831774 IG Page Info ----------------------- @crimewatchusa Owned by: CrimeWatchUSA ID: 17841456740681690 IG Page ID FB Page ID {"instagram_business_account":{"id":"17841456740681690"},"id":"114163234831774"} HAD TO GENERATE PAGE ACCESS PERMISSIONS FOR IG My app is a server app that will programmatically update my IG business product page with my advertisers content. - a script runs 24/7 that checks for advertisers content to be published - once the advisters content is found the script will make a call to the Graph API instagram_content_publish to update my IG business product page with the advertisers content I would like to use the instagram_content_publish to simply post photos or videos to a Instagram business account. I would like to use the instagram_content_publish to simply post photos or videos to a Instagram business account. Search news feeds (e.g. cnn.com, nbc.com, etc) for news stories to post to my community service instagram account | If news stories found for each story save the photo / video and caption tothe local server hard drive | Make a call to the Graph API using the instagram_basic and instagram_content_publish permissions to post the each news story found | Wait 60 minutes and loop back to search the news feed for additional stories to post to my community service instagram account how can I create and test my app if I cannot get permission to use the API's that are required by my app? I'm trying to get everything setup so that I can develop the app but I can't get access to the API;'s I need. Please help me figure out what I need to do to continue. Thanks What I am trying to accomplish is fairly straight forward. Instead of manually posting to my instagram account I want to automatically post to my account from my desktop PC using a script. The script will be used to setup everything I need (such as the photo/video, caption, access tokens, etc) to allow me to post to my instagram account. I only need access permission to my account.