Happyr / LinkedIn-API-client

A library to connect with LinkedIn API. Perfect if you are looking for an API client or SDK for LinkedIn
MIT License
198 stars 97 forks source link

Class 'Http\Discovery\MessageFactoryDiscovery' not found... in /Http/RequestManager.php(line 83) #136

Closed nirjharlo closed 7 years ago

nirjharlo commented 7 years ago
Q A
Bug? no
New Feature? no
Are you using composer? no
Version 58bb3bca346e2c709f5aa474c75a9bca6d91ad9a

Actual Behavior

Throws error at HappyR\LinkedIn\LinkedIn->get('v1/people/~:(firstName,lastName)');

Expected Behavior

Pass the access token and fetch the data.

Steps to Reproduce

Created an autoload.php as following inside /src and called the files as I'm doing it from WordPress and didn't use Composer.

<?php
require_once __DIR__.'/Exception/LinkedInException.php';
require_once __DIR__.'/Exception/InvalidArgumentException.php';
require_once __DIR__.'/Exception/LinkedInTransferException.php';
require_once __DIR__.'/Exception/LoginError.php';

require_once __DIR__.'/Http/CurrentUrlGeneratorInterface.php';
require_once __DIR__.'/Http/GlobalVariableGetter.php';
require_once __DIR__.'/Http/LinkedInUrlGeneratorInterface.php';
require_once __DIR__.'/Http/RequestManagerInterface.php';
require_once __DIR__.'/Http/RequestManager.php';
require_once __DIR__.'/Http/ResponseConverter.php';
require_once __DIR__.'/Http/UrlGeneratorInterface.php';
require_once __DIR__.'/Http/UrlGenerator.php';

require_once __DIR__.'/Storage/DataStorageInterface.php';
require_once __DIR__.'/Storage/BaseDataStorage.php';
require_once __DIR__.'/Storage/IlluminateSessionStorage.php';
require_once __DIR__.'/Storage/SessionStorage.php';

require_once __DIR__.'/AccessToken.php';
require_once __DIR__.'/AuthenticatorInterface.php';
require_once __DIR__.'/Authenticator.php';
require_once __DIR__.'/LinkedInInterface.php';
require_once __DIR__.'/LinkedIn.php';
?>

Then called:

require_once __DIR__.'/LinkedIn/autoload.php';

$linkedIn = new HappyR\LinkedIn\LinkedIn('User_ID', 'User_secret);
$linkedInUrl = $linkedIn->getLoginUrl(array( 'redirect_uri' => 'http://teachfinder.com/log-in?role=teacher' ));
if ( isset( $_GET['code'] ) ) {
    $user=$linkedIn->get('v1/people/~:(firstName,lastName)');
    var_dump($user);
}

See live: http://teachfinder.com/log-in/ Select TEACHER and LOG IN WITH LINKEDIN

Possible Solutions

I was trying to find out \Http\Message\MessageFactory including this could possibly solve the problem.

Nyholm commented 7 years ago

Thank you for a detailed issue. It really helps me debugging this.

You see this issue because you do not use Composer. To solve the issue, download composer and run:

composer require php-http/curl-client guzzlehttp/psr7 php-http/message happyr/linkedin-api-client

Then you can use composer's autoload.

require_once "vendor/autoload.php";

$linkedIn=new Happyr\LinkedIn\LinkedIn('client_id', 'client_secret');
Nyholm commented 7 years ago

Closing due inactivity.

KrishnaVishwakarma1595 commented 6 years ago

Hey Nyholm,

I'm also having the same problem stated as above but in my case, I can't access the user profile as it Throws error at HappyR\LinkedIn\LinkedIn->get('v1/people/~:(firstName,lastName)');

I'm using composer and your given composer.json file from the GitHub and when I hit this command "composer install" on cmd it gives an exception as

[RuntimeException] Failed to clone https://github.com/php-http/discovery.git, git was not found,

Nyholm commented 6 years ago

As your Exception message says:

Failed to clone https://github.com/php-http/discovery.git, git was not found,

It seams like you need to install git. Please refer to StackOverflow for issues like this. It is not an issue with this library.

KrishnaVishwakarma1595 commented 6 years ago

Hey Nyholm,

Thank you for your quick response.I didn't know about git installation.Thanks for your quick help.