Topic-icon Extending JLinkedApiLibrary class to pass redirect url

Active Subscriptions:

None
Hello.

I am trying to create a class that would pass the redirect url to oauth, here:
class JLinkedApiLibraryX extends JLinkedApiLibrary
{
    // Override model's getInstance to really only get the instance
    protected $configModel;
    protected $memberId;
    protected $mappedFbUserId;
    protected $retryCount = 0;
    protected $timestampOffset = null;
    private static $libraryInstance;

    public static function getInstance($returl)
    {
        if (!isset(self::$libraryInstance))
        {
            self::$libraryInstance = new JLinkedApiLibraryX($returl);
            // After the instance is grabbed, get the Javascript code to insert
            // Don't do this in the constructor as inititing the Javascript calls functions which need
            //   this very instance
            $app = JFactory::getApplication();
            if (!$app->isAdmin())
            {
                // Set whether, on this page load, the user should be checked for a new mapping (i.e. they were just on the login/register page)
                $session = JFactory::getSession();
                $checkNewMapping = $session->get('jLinkedCheckNewMapping', false);
                self::$libraryInstance->checkNewMapping = $checkNewMapping;
            }
        }
        return self::$libraryInstance;
    }

    function __construct($returl)
    {
        $this->getConfigModel();
        $this->setTimestampOffset($this->configModel->getSetting('linkedin_oauth_timestamp_offset'));
        $this->findLocalAccessToken(); // Search for an access token and set it

        $return = ''; $menuItemId = 0;
        SCSocialUtilities::getCurrentReturnParameter($return, $menuItemId, LOGIN_TASK_JLINKED);

        $linkedInApiKey = $this->configModel->getSetting('linkedin_api_key');
        $linkedInSecretKey = $this->configModel->getSetting('linkedin_secret_key');
		$callbackUrl = $returl;
        if (!$callbackUrl) $callbackUrl = JURI::root() . 'index.php?option=com_jlinked&task=linkedInCallback&return='.base64_encode($return);
        $config = array('appKey' => $linkedInApiKey, 'appSecret' => $linkedInSecretKey, 'callbackUrl' => $callbackUrl);
        parent::__construct($config);
    }

}

Seems like no big deal, though it still would redirect me to login screen (which is set in jlinked options) if i'm not logged in with joomla.

How can i make this work, or maybe should I be hacking the controller instead (linkedinCallback)?
The topic has been locked.
Support Specialist
Can you explain a bit more about what you're actually trying to accomplish? I'm not really sure what the end-goal is, so I can't look at the code to tell you if it's on the right track.

Also, you're obviously still using JLinked. If possible, I'd recommend upgrading to JFBConnect. The code is cleaner, uses Oauth 2 (which is simpler) and has a lot of other features for other social networks.

Either way, let me know more details, and we'll help however we can.

Thanks,
Alex
The topic has been locked.