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?
www.linkedin.comCURLOPT_DNS_USE_GLOBAL_CACHE => falseandCURLOPT_DNS_CACHE_TIMEOUT => 2as part of your curl options