I have a controller Callback.php
in folder app/code/Dots/Socialfeeds/Controller/Social
in custom module Dots_Socialfeeds
.
I am also using an third party library file Linkedin.php
which I have placed in folder lib/external/Dots/Socialfeeds/Linkedin
.
Now I want to use this lib class in my above controller Callback.php
.
code--
<?php
namespace Dots\Socialfeeds\Controller\Social;
use Magento\Framework\App\Action\Action;
use Dots\Socialfeeds\Linkedin\Linkedin;
/**
* Class Callback
*
* @package Dots\Socialfeeds\Controller\Social
*/
class Callback extends Action
{
/**
* @inheritdoc
*/
public function execute()
{
$li = new \Linkedin(
array(
'api_key' => '81a592y6mz9o33',
'api_secret' => 'kviv5GtPAt3ZDHpq',
'callback_url' => 'http://ds01.projectstatus.co.uk/c2cwp/test.php?type=linkedin'
)
);
$token = $li->getAccessToken($_GET['code']);
}
}
and lib file code --
<?php
namespace Dots\Socialfeeds\Linkedin;
class Linkedin
{
private $_config = array();
private $_state = null;
private $_access_token = null;
private $_access_token_expires = null;
private $_debug_info = null;
private $_curl_handle = null;
const API_BASE = 'https://api.linkedin.com/v1';
const OAUTH_BASE = 'https://www.linkedin.com/uas/oauth2';
const SCOPE_BASIC_PROFILE = 'r_basicprofile'; // Name, photo, headline, and current positions
const SCOPE_FULL_PROFILE = 'r_fullprofile'; // Full profile including experience, education, skills, and recommendations
const SCOPE_EMAIL_ADDRESS = 'r_emailaddress'; // The primary email address you use for your LinkedIn account
const SCOPE_NETWORK = 'r_network'; // Your 1st and 2nd degree connections
const SCOPE_CONTACT_INFO = 'r_contactinfo'; // Address, phone number, and bound accounts
const SCOPE_READ_WRITE_UPDATES = 'rw_nus'; // Retrieve and post updates to LinkedIn as you
const SCOPE_READ_WRITE_GROUPS = 'rw_groups'; // Retrieve and post group discussions as you
const SCOPE_READ_WRITE_COMPANY_ADMIN = 'rw_company_admin'; // Administers a company as you
const SCOPE_WRITE_MESSAGES = 'w_messages'; // Send messages and invitations to connect as you
const SCOPE_WRITE_SHARE = 'w_share'; // Share url to your contacts
const HTTP_METHOD_GET = 'GET';
const HTTP_METHOD_POST = 'POST';
const HTTP_METHOD_PUT = 'PUT';
const HTTP_METHOD_DELETE = 'DELETE';
/**
* @param array $config (api_key, api_secret, callback_url)
* @throws \InvalidArgumentException
* @throws \RuntimeException
*/
public function __construct(array $config)
{
if (!isset($config['api_key']) || empty($config['api_key'])) {
throw new \InvalidArgumentException('Invalid api key - make sure api_key is defined in the config array');
}
if (!isset($config['api_secret']) || empty($config['api_secret'])) {
throw new \InvalidArgumentException('Invalid api secret - make sure api_secret is defined in the config array');
}
if (!isset($config['callback_url']) || empty($config['callback_url'])) {
throw new \InvalidArgumentException('Invalid callback url - make sure callback_url is defined in the config array');
}
if (!extension_loaded('curl')) {
throw new \RuntimeException('PHP CURL extension does not seem to be loaded');
}
$this->_config = $config;
}
.....
.....
I am getting error if in controller file-
Fatal error: Uncaught Error: Class 'Linkedin' not found in app/code/Dots/Socialfeeds/Controller/Social/Callback.php:24