ViadeoCompany.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. class ViadeoCompany extends BridgeAbstract{
  3. public function loadMetadatas() {
  4. $this->maintainer = "regisenguehard";
  5. $this->name = "Viadeo Company";
  6. $this->uri = "https://www.viadeo.com/";
  7. $this->description = "Returns most recent actus from Company on Viadeo. (http://www.viadeo.com/fr/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 = 'http://www.viadeo.com/fr/company/'.$param[c];
  20. $html = $this->file_get_html($link) or $this->returnError('Could not request Viadeo.', 404);
  21. foreach($html->find('//*[@id="company-newsfeed"]/ul/li') as $element) {
  22. $title = $element->find('p', 0)->innertext;
  23. if ($title) {
  24. $item = new \Item();
  25. $item->uri = $link;
  26. $item->title = mb_substr($element->find('p', 0)->innertext, 0 ,100);
  27. $item->content = $element->find('p', 0)->innertext;
  28. $item->thumbnailUri = str_replace('//', 'http://', $element->find('img.usage-article__image_only', 0)->src);
  29. $this->items[] = $item;
  30. $i++;
  31. }
  32. }
  33. }
  34. public function getName(){
  35. return 'Viadeo';
  36. }
  37. public function getURI(){
  38. return 'https://www.viadeo.com';
  39. }
  40. public function getCacheDuration(){
  41. return 21600; // 6 hours
  42. }
  43. }