Closed Vivatec closed 4 years ago
Did you initialize the class?
use EspressoDev\InstagramBasicDisplay\InstagramBasicDisplay;
$instagram = new InstagramBasicDisplay([
'appId' => 'YOUR_APP_ID',
'appSecret' => 'YOUR_APP_SECRET',
'redirectUri' => 'YOUR_APP_REDIRECT_URI'
]);
Yes. I reported the three data that were taken from developers.facebook. After clicking the link he is redirected to the Instagram confirmation page. I click on confirm and go back to my website, however with that error message.
I thank you for your help and sorry for the bad English.
Could you share the code you use to get the oauth token?
It includes a link with the image of the codes of the two pages that are used.
The code is exactly what you suggested in the examples.
Yes, it happens because you are not instantiating an instance of the class in the redirect URL.
You will need to add this to your redirect page code:
$instagram = new InstagramBasicDisplay([
'appId' => 'YOUR_APP_ID',
'appSecret' => 'YOUR_APP_SECRET',
'redirectUri' => 'YOUR_APP_REDIRECT_URI'
]);
That's exactly what I'm doing.
require __DIR__ . '/vendor/autoload.php'; use EspressoDev\InstagramBasicDisplay\InstagramBasicDisplay; $instagram = new InstagramBasicDisplay([ 'appId' => '000000000', 'appSecret' => 'xxxxxxxxxxx', 'redirectUri' => 'https://iboy.com.br/auth.php' ]); echo "<a href='{$instagram->getLoginUrl()}'>Login with Instagram</a>";
After the Instagram confirmation screen I am directed to the page where the error occurs.
The error occurs in this second step: https://iboy.com.br/auth.php?code=XXXXXXXXXXXXX...
require __DIR__ . "/vendor/autoload.php"; use EspressoDev\InstagramBasicDisplay\InstagramBasicDisplay; $code = $_GET['code']; $token = $instagram->getOAuthToken($code, true); // the error occurs on that line echo "Your token is: " . $token;
Where on the page that the error occurs are you instantiating the class? I'm not seeing in your screenshot.
You need to add this to that page:
$instagram = new InstagramBasicDisplay([ 'appId' => '000000000', 'appSecret' => 'xxxxxxxxxxx', 'redirectUri' => 'https://iboy.com.br/auth.php' ]);
I'm not sure how else to make this clear to you.
I'm sorry for the stupidity. There was no understand that it was to insert in the other file too.
It worked.
Thank you for your help
Hello,
When trying to authenticate the user (OAuth2), I get the following error message: Fatal error: "Uncaught Error: Call to a member function getOAuthToken () on null in" Refers to that line: $token = $instagram->getOAuthToken($code, true);
Do you have any idea what could be causing this? Thank you