LinkedInCompany.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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->parameters[] = array(
  9. 'c'=>array(
  10. 'name'=>'Company name',
  11. 'required'=>true
  12. )
  13. );
  14. }
  15. public function collectData(array $param){
  16. $html = '';
  17. $link = 'https://www.linkedin.com/company/'.$param['c'];
  18. $html = $this->getSimpleHTMLDOM($link) or $this->returnServerError('Could not request LinkedIn.');
  19. foreach($html->find('//*[@id="my-feed-post"]/li') as $element) {
  20. $title = $element->find('span.share-body', 0)->innertext;
  21. if ($title) {
  22. $item = array();
  23. $item['uri'] = $link;
  24. $item['title'] = mb_substr(strip_tags($element->find('span.share-body', 0)->innertext), 0 ,100);
  25. $item['content'] = strip_tags($element->find('span.share-body', 0)->innertext);
  26. $this->items[] = $item;
  27. $i++;
  28. }
  29. }
  30. }
  31. public function getCacheDuration(){
  32. return 21600; // 6 hours
  33. }
  34. }