S
S
Sergey2014-08-21 16:32:45
PHP
Sergey, 2014-08-21 16:32:45

What is wrong in my work with instagram api?

In general, I use this class: https://github.com/cosenary/Instagram-PHP-API
it seems like the authorization passed and redirected me to the page I needed.
Those. this code in index.php works:

<?php
$instagram = new Instagram(array(
  'apiKey'      => 'key',
  'apiSecret'   => 'secret',
  'apiCallback' => 'http://www.insta.dev/api/example/success.php'
));

// create login URL
$loginUrl = $instagram->getLoginUrl();

?>

<a class="login" href="<? echo $loginUrl ?>">» Login with Instagram</a>

After authorization, I get to success.php and get a code.
Next I try to work with it:
$code = $_GET['code'];


if (isset($code)) {

  // receive OAuth token object
  $data = $instagram->getOAuthToken($code);
  var_dump($data);
}

Well, I actually see the result:

object(stdClass)#2 (3) { ["code"]=> int(400) ["error_type"]=> string(14) "OAuthException" ["error_message"]=> string(48) "Redirect URI doesn't 't match original redirect URI" }

What to do and how to avoid mistakes - I can not find.
In success.php I create a new object with the same data as in index.
How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
1
1Michael1, 2014-08-21
@butteff

login url is being built correctly? domain in the form of www.insta.dev/... ?
there may be another problem on the local host (if deployed on a vps, for example, it will work)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question