0

I'm using a class found on Github (Happyr\Linkedin) to connect to Linkedin API and create a login. It worked fine, with no problem whatsoever until it didn't work anymore, but without doing any changes at all.

This is my call code:

$linkedIn=new Happyr\LinkedIn\LinkedIn('apikey', 'apisecret');

session_start();

if ($linkedIn->isAuthenticated() && isset($_GET['code'])) {

    $user=$linkedIn->get('v1/people/~:(firstName,lastName,id,picture-url)');
    if ($user){
      $_user = User::where('linkedin_id', $user['id'])->first();

      if (!$_user) {
        //create user and login
        header("Location: search.php");
        exit();
      } else {
        //login user
        header("Location: search.php");
        exit();
      }
    }

What I'm receiving is an exception in one of the vendor packages:

Fatal error: Uncaught Http\Client\Exception\NetworkException: Could not resolve host: www.linkedin.com in /var/www/html/vendor/php-http/curl-client/src/Client.php:134 Stack trace: 
#0 /var/www/html/vendor/happyr/linkedin-api-client/src/Http/RequestManager.php(37): Http\Client\Curl\Client->sendRequest(Object(GuzzleHttp\Psr7\Request))
#1 /var/www/html/vendor/happyr/linkedin-api-client/src/Authenticator.php(124): Happyr\LinkedIn\Http\RequestManager->sendRequest('POST', 'https://www.lin...', Array, 'grant_type=auth...')
#2 /var/www/html/vendor/happyr/linkedin-api-client/src/Authenticator.php(76): Happyr\LinkedIn\Authenticator->getAccessTokenFromCode(Object(Happyr\LinkedIn\Http\UrlGenerator), 'AQTWSqlSdfv3Fy_...')
#3 /var/www/html/vendor/happyr/linkedin-api-client/src/LinkedIn.php(293): Happyr\LinkedIn\Authenticator->fetchNewAccessToken(Object(Happyr\LinkedIn\Http\UrlGenerator))
#4 /var/www/html/vendor/happyr/linkedin-api-client/src/LinkedIn.php(95): Happyr\LinkedIn\LinkedIn->getAccessToken()
#5 /var/www/html/index.php(9): Happ in /var/www/html/vendor/happyr/linkedin-api-client/src/Authenticator.php on line 128

Any idea on how can I solve this?

4
  • Looks like something is wrong with your network configuration. Looks like for whatever reason you script can not find host www.linkedin.com Commented Mar 22, 2017 at 22:45
  • @E_p I pinged linkedin from the server, looks like it is ok. What could be wrong in network configuration? The only activity was that the Digital Ocean Droplet was closed for several hours, closed by DO staff due to payment. Could something happened when the droplet is closed that could affect the network configuration? Commented Mar 22, 2017 at 23:34
  • 1
    For starters it can be proxy and firewall. Than you need to look in too your php configuration some features/modules can be turned off. Commented Mar 22, 2017 at 23:35
  • You can also try to pass CURLOPT_DNS_USE_GLOBAL_CACHE => false and CURLOPT_DNS_CACHE_TIMEOUT => 2 as part of your curl options Commented Mar 22, 2017 at 23:38

1 Answer 1

1

Update you composer.lock file and try again.

Sign up to request clarification or add additional context in comments.

1 Comment

this sounds more like a comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.