LinkedInCompany.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. class LinkedInCompany extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "regisenguehard";
  5. $this->name = "LinkedIn Company";
  6. $this->uri = "https://www.linkedin.com/";
  7. $this->description = "Returns most recent actus from Company on LinkedIn. (https://www.linkedin.com/company/<strong style=\"font-weight:bold;\">apple</strong>)";
  8. $this->update = "2015-12-22";
  9. $this->parameters[] =
  10. '[
  11. {
  12. "name" : "Company name",
  13. "identifier" : "c"
  14. }
  15. ]';
  16. }
  17. public function collectData(array $param){
  18. $html = '';
  19. $link = 'https://www.linkedin.com/company/'.$param[c];
  20. $html = $this->file_get_html($link) or $this->returnError('Could not request LinkedIn.', 404);
  21. foreach($html->find('//*[@id="my-feed-post"]/li') as $element) {
  22. $title = $element->find('span.share-body', 0)->innertext;
  23. if ($title) {
  24. $item = new \Item();
  25. $item->uri = $link;
  26. $item->title = mb_substr(strip_tags($element->find('span.share-body', 0)->innertext), 0 ,100);
  27. $item->content = strip_tags($element->find('span.share-body', 0)->innertext);
  28. $item->thumbnailUri = htmlspecialchars_decode($element->find('img', 0)->attr['data-li-lazy-load-src']);
  29. $this->items[] = $item;
  30. $i++;
  31. }
  32. }
  33. }
  34. public function getName(){
  35. return 'LinkedIn';
  36. }
  37. public function getURI(){
  38. return 'https://www.linkedin.com';
  39. }
  40. public function getCacheDuration(){
  41. return 21600; // 6 hours
  42. }
  43. }