espresso-dev / instagram-basic-display-php

A simple PHP class for accessing the Instagram Basic Display API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Idea: Add state param for getLoginUrl()

movingwater opened this issue · comments

Hi, thanks for this wrapper. It's really great and easy to work with.

For my project I also use the state param (reference) to add additional information. it would be awesome if you could add this to the getLoginUrl() function. Maybe as a second variable like so:

    public function getLoginUrl($scopes = ['user_profile', 'user_media'], $state = '')
    {
        if (is_array($scopes) && count(array_intersect($scopes, $this->_scopes)) === count($scopes)) {
            return self::API_OAUTH_URL . '?app_id=' . $this->getAppId() . '&redirect_uri=' . urlencode($this->getRedirectUri()) . '&scope=' . implode(',',
                $scopes) . '&response_type=code' . ($state != '' ? '&state=' . $state : '');
        }

        throw new InstagramBasicDisplayException("Error: getLoginUrl() - The parameter isn't an array or invalid scope permissions used.");
    }

or maybe you have a better solution? thanks for your effort.

👍 This sounds like a good idea. You want to do a PR?