Enrique Moreno Tent
Enrique Moreno Tent

Reputation: 25307

Instagram API: I get no access_token

I am using this PHP Instagram Client to try to access the API of Instagram, but every time I try to access it, I get this message in return:

object(stdClass)#4 (1) {
  ["meta"]=>
  object(stdClass)#2 (3) {
    ["code"]=>
    int(400)
    ["error_type"]=>
    string(25) "OAuthAccessTokenException"
    ["error_message"]=>
    string(37) "The access_token provided is invalid."
  }
}

and I cannot figure out what I am doing wrong.

This is my code so far:

$instagram = new MetzWeb\Instagram\Instagram('......');
$result = $instagram->getPopularMedia();
var_dump($result);

When I check my $instagram object, the data inside does not seem right, as there seems to be no access token.

object(MetzWeb\Instagram\Instagram)#3 (7) {
  ["_apikey":"MetzWeb\Instagram\Instagram":private]=>
  string(32) "...."
  ["_apisecret":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_callbackurl":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_accesstoken":"MetzWeb\Instagram\Instagram":private]=>
  NULL
  ["_signedheader":"MetzWeb\Instagram\Instagram":private]=>
  bool(false)

What is it that I am missing?

Upvotes: 1

Views: 702

Answers (1)

reinierkors
reinierkors

Reputation: 510

As you can see on the github repo:

Note: On the 17 Nov 2015 Instagram made changes to their API . Apps created before Nov 17, 2015 wont be affected until Jun 2016. Apps created on or after Nov 17 2015 will require to use their updated API. Please note that this library doesn't yet support their new updates. For more information, please see #182.

Meaning the library does not yet support the latest Instagram API.

UPDATE: Instagram only allows authenticated API calls, no public calls anymore.

The only way to bypass public calls is by 'scraping' data from Instagram. There are a couple of scrapers out there.

It basically fetches: https://www.instagram.com/jerryseinfeld/media/ and parses the JSON. You can fetch all tags by getting the #tags from the message.

Upvotes: 3

Related Questions