I would like to show my company Linkedin feed on my website (a WordPress site),For fetching LinkedIn feeds, i created LinkedIn company page and post some feeds on that page. After that i created app on https://www.linkedin.com/developer/, i and got client ID, client Secret Key, i also got access token of my app. But i'm not understanding, how can i make LinkedIn API so that i can display LinkedIn feeds on my website. Actually i don't want to display feeds by iframe way. I want display feeds on my custom html. I have tried Using PHP LinkedIn SDK as following.
$li = new LinkedIn(array(
'api_key' => "client secret",
'api_secret' => "client ID",
'callback_url' => "redirecturl"
));
$token = $li->setAccessToken('Your access token');
$feeds = $li->fetch('GET', '/v2/companies/company-id/updates?event-type=status-update&start=0&count=6&format=json');
$posts = $li->get('/companies/79097881/updates/');
$pages = json_decode(file_get_contents($posts));
echo "<pre>"; print_r($pages);
But i didn't get anything. So please provide me some solution.
My Answer:
It looks like you are on the right track with using the PHP LinkedIn SDK to fetch and display LinkedIn feeds on your website. However, there are a few things you may need to check and adjust in your code:
1. Make sure you have the correct API key, API secret, and access token from your LinkedIn app. Double-check that these values are correctly entered in your code.
2. Ensure that your LinkedIn company page ID is correct in the API request. You can find your company page ID by visiting your company page on LinkedIn and looking at the URL. It should be in the format of /companies/{company-id}/updates.
3. Check the permissions of your LinkedIn app. Make sure that your app has the necessary permissions to access company updates.
4. Verify that your API request is correctly formatted. The endpoint for fetching company updates should be '/v2/companies/{company-id}/updates?event-type=status-update&start=0&count=6&format=json'.
5. Make sure that your LinkedIn SDK is properly set up and initialized before making API requests.
If you have checked all of the above and are still not getting any results, you may want to consider debugging your code further or reaching out to the LinkedIn developer support for assistance. Additionally, you can also explore other libraries or methods for fetching LinkedIn feeds in PHP.
Rate this post
3 of 5 based on 4091 votesComments