Advertisement
Guest User

Untitled

a guest
Sep 30th, 2014
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. <?php
  2.  
  3. class ReportAPI
  4. {
  5. protected $reportDataObject = null;
  6.  
  7. public function __construct($url = 'URL', $username = 'username', $password = 'pass') {
  8. $this->client = new SoapClient($url , array('login' => $username, 'password' => $password, 'keep_alive' => true));
  9. }
  10. public function getReportData($reportID) {
  11. return $this->getDataObject($reportID)->data;
  12. }
  13. public function getReportCount($reportID) {
  14. return $this->getDataObject($reportID)->result_count;
  15. }
  16. public function runReport($reportID) {
  17. $newID = $this->client->runReport($reportID);
  18. $counter = 0;
  19. while($this->client->checkReportRun($newID) != 'complete'){
  20. if($counter > 2) {
  21. throw new Exception('Report Time Out');
  22. }
  23. sleep(5);
  24. $counter++;
  25. }
  26. $this->getDataObject($newID);
  27. return $newID;
  28. }
  29.  
  30. public function functest() {
  31. $v0 = $this->getDataObject('id')->result_count;
  32. return $this->getDataObject('id')->data;
  33. }
  34.  
  35. public function getLatestID($reportID) {
  36. $runlist = $this->client->getReportRunList($reportID);
  37. return $runlist[0][0];
  38. }
  39.  
  40. public function getLatestReportData($reportID) {
  41. return $this->getReportData($this->getLatestID($reportID));
  42. }
  43.  
  44. public function getTitles($reportID) {
  45. return $this->getDataObject($reportID)->columns;
  46. }
  47.  
  48. public function getReportRunTime($reportID) {
  49. $runlist = $this->client->getReportRunList($reportID);
  50. return strtotime($runlist[0][2]);
  51. }
  52.  
  53. public function getRawReport($reportID) {
  54. return $this->client->getReportDataObject($reportID);
  55. }
  56.  
  57. protected function getDataObject($reportID) {
  58. if(!isset($this->reportDataObject) || $this->reportDataObject->report_run_id != $reportID) {
  59. $this->reportDataObject = $this->client->getReportDataObject($reportID);
  60. }
  61. return $this->reportDataObject;
  62. }
  63. }
  64.  
  65. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement