【问题标题】:API REST LINKEDIN for sourcingAPI REST LINKEDIN 用于采购
【发布时间】:2018-05-10 15:51:16
【问题描述】:

晚上好, 我想使用 LinkedIn REST API 从人们那里收集信息,例如电子邮件名称、体验... 我使用 Ionic 3 基于 4 角度 使用此页面中的说明 https://developer.linkedin.com/docs/rest-api 没有结果 通过这个页面https://www.myprogrammingtutorials.com/linkedin-api-using-php-get-users-data.html,他给了我一个访问令牌错误 如果您有任何建议,请提前感谢您...! ?? 这是我的代码

<!-- search_link.php -->
<!DOCTYPE html>
<html>
<head>
     <title>search</title>
</head>
<body>
<form method="get" action="result_link.php">
     <input type="text" name="code">
     <input type="submit" name="">
     
</form>
</body>
</html>

<!-- result_link.php -->
   

 <?php
if(isset($_GET['code'])){
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL,"https://www.linkedin.com/oauth/v2/accessToken");
	curl_setopt($ch, CURLOPT_POST, 0);
	curl_setopt($ch, CURLOPT_POSTFIELDS,"grant_type=authorization_code&code=".$_GET['code']."&redirect_uri=http://localhost:80/linkedin_search/result_link.php&client_id={ID_CLIENT}&client_secret={SECRET_CLIENT}");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
	$server_output = curl_exec ($ch);
	curl_close ($ch);
}

if(isset($_GET['code']) && json_decode($server_output)->access_token != ''){

     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL,"https://api.linkedin.com/v1/people/~?oauth2_access_token=".json_decode($server_output)->access_token."&format=json");
     curl_setopt($ch, CURLOPT_POST, 0);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     $server_output2 = curl_exec ($ch);
     curl_close ($ch);

     $user_data = json_decode($server_output2);

     print_r($user_data);

}
?>

【问题讨论】:

  • 有什么帮助吗?
  • ?????????????????????????????????????????? ??????????????????????????????????????????????????? ??????????????????????????????????????????????????? ?????????????????????????????????

标签: javascript html rest ionic3 linkedin-api


【解决方案1】:

我们需要做的第一件事是,通过下面的按钮授权应用中的链接

<a href="https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_id={CLIENT_ID}&redirect_uri={REDIRECT_URL}&state=987654321&scope=r_basicprofile">Register With LinkedIn</a>

它将代码 ($_GET['code']) 发送回我们提供的 REDIRECT_URL

【讨论】:

    猜你喜欢
    • 2021-10-09
    • 1970-01-01
    • 2015-02-02
    • 2020-08-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多