Lance
Lance

Reputation: 4820

Fetching data with the Instagram API via cron jobs

I have this script the logs a user into Instagram much like the found here. Once the user is logged in and an access token is generated, the user is redirected to the redirect_uri, but with the $_GET['code'] variable in the URL. Once the redirect_uri is loaded, a script is executed that loops thru an array of Instagram account ID's and gets info about each page. The problem is that the same code variable that's in the URL cannot be used more than once. Refreshing the page will not successfully get any info about the Instagram accounts because it needs to be unique.

So, here is my question: can the script that is executed once the redirect_uri is loaded be executed via crons? I'm not sure how a cron would log into Instagram. Any ideas?

Upvotes: 0

Views: 1284

Answers (1)

chrisboustead
chrisboustead

Reputation: 1563

You can discard the code variable once the page is loaded, and only store and use the access token (in a database or file on server) to make API calls, which as of right now does not expire and can be re-used.

Upvotes: 0

Related Questions