1
0

OpenClassroomsBridge.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * RssBridgeOpenClassrooms
  4. * Retrieve lastest tutorials from OpenClassrooms.
  5. * Returns the most recent tutorials, sorting by date (most recent first).
  6. * 2014-05-25
  7. *
  8. * @name OpenClassrooms Bridge
  9. * @homepage http://fr.openclassrooms.com/
  10. * @description Returns latest tutorials from OpenClassrooms.
  11. * @maintainer sebsauvage
  12. * @use1(u="informatique or sciences")
  13. */
  14. class OpenClassroomsBridge extends BridgeAbstract{
  15. public function collectData(array $param){
  16. if ($param['u']!='informatique' && $param['u']!='sciences')
  17. {
  18. $this->returnError('Error: You must chose "informatique" or "science".', 404);
  19. }
  20. $html = '';
  21. $link = 'http://fr.openclassrooms.com/'.$param['u'].'/cours?title=&sort=updatedAt+desc';
  22. $html = file_get_html($link) or $this->returnError('Could not request OpenClassrooms.', 404);
  23. foreach($html->find('li.col6') as $element) {
  24. $item = new \Item();
  25. $item->uri = 'http://fr.openclassrooms.com'.$element->find('a', 0)->href;
  26. $item->title = $element->find('div.courses-content strong', 0)->innertext;
  27. $item->content = $element->find('span.course-tags', 0)->innertext;
  28. $this->items[] = $item;
  29. }
  30. }
  31. public function getName(){
  32. return 'OpenClassrooms';
  33. }
  34. public function getURI(){
  35. return 'http://fr.openclassrooms.com';
  36. }
  37. public function getCacheDuration(){
  38. return 21600; // 6 hours
  39. }
  40. }