我是一个LinkedIn公司页面的所有者和管理员:https://www.linkedin.com/company/{id}/。
我想连接到LinkedIn,并在我的公司墙上返回一个包含最新10个帖子的JSON-feed,以显示在我的网站上,因此我接触到了服务https://api.linkedin.com/v1/companies/{id}/updates?format=json。
JSON以linkedin.php格式输出。然后这个文件就会包含在我的网页中,比如index.php。
我已经在https://developer.linkedin.com注册了一个应用程序。我已经在https://github.com/ashwinks/PHP-LinkedIn-SDK提供的PHP-LinkedIn-SDK中输入了我的客户端ID和客户端密码。
我遵循了需要首先进行身份验证的开发人员文档。当我运行linkedin.php时,我被重定向到登录我的LinkedIn个人资料。我必须完成这一步才能接触到上面的服务。
使用当前的解决方案,我的用户在访问我的网站时必须登录到LinkedIn。
如何在不提示用户登录的情况下访问公司的LinkedIn帖子列表?
谢谢。
发布于 2016-10-24 21:16:14
1.生成访问令牌按照文档https://github.com/ashwinks/PHP-LinkedIn-SDK创建登录链接。
2.保存您的访问令牌一旦获得,有效期为60天。将其保存到数据库中。
3.获取您公司的帖子您可以使用相同的访问令牌来获取公司内容
$li = new LinkedIn(...);
$li->setAccessToken(YOUR_ACCESS_TOKEN);
$posts = $li->get('/companies/YOUR_COMPANY_ID/updates/');4.管理响应缓存或在解析后显示响应。
希望这能有所帮助,
发布于 2019-09-14 00:17:32
使用https://packagist.org/packages/linkedinapi/linkedin
$li = new LinkedIn(
array(
'api_key' => 'yourapikey',
'api_secret' => 'yourapisecret',
'callback_url' => 'https://yourdomain.com/redirecthere'
)
);
//Get the login URL - this accepts an array of SCOPES
$url = $li->getLoginUrl(
array(
LinkedIn::SCOPE_BASIC_PROFILE,
LinkedIn::SCOPE_EMAIL_ADDRESS,
LinkedIn::SCOPE_NETWORK
)
);
/*LinkedIn will redirect to 'callback_url' with an access token as the 'code' parameter. You might want to store the token in your session so the user doesn't have to log in again*/
$token = $li->getAccessToken($_REQUEST['code']);
$token_expires = $li->getAccessTokenExpiration();
//Make a request to the API
$info = $li->get('/people/~:(first-name,last-name,positions)');
$li = new LinkedIn(
array(
'api_key' => 'yourapikey',
'api_secret' => 'yourapisecret',
'callback_url' => 'https://yourdomain.com/redirecthere',
'curl_options' => array(
CURLOPT_PROXY => '127.0.0.1:80',
),
)
)https://stackoverflow.com/questions/31820487
复制相似问题