如何在不需要用户身份验证的情况下从我的公司页面获取Linkedin提要


How to fetch Linkedin feeds from my company page without user having to authenticate

我正试图在我的网站上显示我的linkedin公司页面更新,如图所示。

https://developer.linkedin.com/reading-company-shares

我从这里下载了源代码http://thinkdiff.net/linkedin/integrate-linkedin-api-in-your-site/

并在linkedin.php 中添加了以下方法

function company($parameters)
    {
    //$search_url = $this->base_url."/v1/companies/{$parameters}/updates";
    //$search_url = $this->base_url . "/v1/people-search?keywords=facebook";
    $search_url = "https://api.linkedin.com/v1/companies/918677/updates?";

    echo "Performing search for: " . $parameters . "<br />";
    echo "Search URL: $search_url <br />";
    $request = OAuthRequest::from_consumer_and_token($this->consumer, $this->access_token, "GET", $search_url);
    $request->sign_request($this->signature_method, $this->consumer, $this->access_token);
    $auth_header = $request->to_header("https://api.linkedin.com");
    print_r($auth_header);
    $response = $this->httpRequest($search_url, $auth_header, "GET");
    return $response;
}

我无法使它工作。此外,我试图在用户不必登录的情况下显示它们。有可能吗?任何相同的代码或教程都会有所帮助。

谢谢。。

首先您必须获得linkedin用户的用户令牌使用Socialite或用于oauth的REST API包。

一旦你有了用户令牌,在管理员用户下获取公司列表是非常简单的

$token = 'uflefjefheilhfbwrfliehbwfeklfw';    // user token
$api_url = "https://api.linkedin.com/v1/companies?oauth2_access_token=".$token."&format=json&is-company-admin=true";
$pages = json_decode(file_get_contents($api_url));

您已经获得了公司简介列表的$pagesjson数组。