-1

I downloaded the PHP ews database from https://github.com/jamesiarmes/php-ews.

Autoloader:

function __autoload ($className){
  preg_match ("/^(([a-zA-Z]{5})_)?(.+)$/",$className,&$treffer); # die ersten 5 Stellen=Verzeichnisname, Weitere Zeichen=Dateiname
  if(file_exists(PROJEKT_DIR.$className.".class.php"))  include_once(PROJEKT_DIR.$className.".class.php"); 
  else{
    $pfad=SCRIPT_DIR."include/";
    if($treffer[2]) $pfad.="classes/".$treffer[2]."/";
    if(file_exists($pfad.$treffer[3].".class.php"))
      include_once($pfad.$treffer[3].".class.php");
    elseif(substr($treffer[3],-7)!="_bvstnd" and class_exists($className."_bvstnd")){
      eval("class  $className extends ".$className."_bvstnd {} ");
    }
        else{
        // Start from the base path and determine the location from the class name,
        $pfad=SCRIPT_DIR."include/php-ews";
        $include_file = $pfad . '/' . str_replace('_', '/', $className) . '.php';

        return (file_exists($include_file) ? require_once $include_file : false);

        }
  }

  #if(file_exists(SCRIPT_DIR."include/".$className.".class.php"))
  #  include_once(SCRIPT_DIR."include/".$className.".class.php");
}

it also load some other files.

Then I started doing the Guide from his site, I started doing this:

<?php

$host = "*********";
$username="**********";
$password="***********";
$version= "***********";

$ews = new ExchangeWebServices($host, $username, $password, $version);


$request = new EWSType_FindFolderType();
$request->Traversal = EWSType_FolderQueryTraversalType::SHALLOW;

$request->FolderShape = new EWSType_FolderResponseShapeType();

$request->FolderShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;

// configure the view
$request->IndexedPageFolderView = new EWSType_IndexedPageViewType();

$request->IndexedPageFolderView->BasePoint = 'Beginning';
$request->IndexedPageFolderView->Offset = 0;

// set the starting folder as the inbox
$request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();

$request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();

$request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::INBOX;

// make the actual call
$response = $ews->FindFolder($request);

?>

At first the Site at the browser just load very long but then tell me something like this: class Exception is undefined. I can't tell the correct message because now this Message doesn´t even show up if I load the script.

The Browser just load infinitely. After this I can't even connect to my server with my PHP files. I have to open my other Browser to connect again.

If I open up the script in my other Browser then I can run the script again but it´s again loading infinity. (I include all my files I need with autoloader so that's not the Problem)

Does anybody have a Problem like that and found a solution?

Xymz
  • 21
  • 5
  • something like that? or exactly like that? I assume it was something else, e.g. one of the exceptions from that library, that can't be found because you did not load the class: I don't see the autoloader anywere that is mentioned in that link. try adding that? – Nanne Mar 20 '15 at 14:21
  • Where should i adding what? What do you mean? – Xymz Mar 20 '15 at 14:40
  • 1
    If you check that github page, you see a howto that has a segment "autoloading". You have created an autoloader, but I don't see you calling it. I suspect this is the problem but as you have not show the actual error message I cannot be sure. I suspect it says something about an Exception subclass, and then my autoloader theory would be feasibly. So you might want to add the autoloader-code to your ews code, and you definitely want to add the verbatim error to your question. – Nanne Mar 20 '15 at 14:45
  • I include at the start a file where the autoloader is getting loaded everytime . If i wouldn´t do that the script wouldn´t even run "$ews = new ExchangeWebServices($host, $username, $password, $version); ". I would like to write the error message but i cant load the script in the Browser anymore. if i get the message one more time i will post it as soon as possible – Xymz Mar 20 '15 at 14:49
  • @Nanne Got now the error message again after i let the site load over 5 hours. Here it is "class EWS_Exception is undefined". but every File is at my workspace and is included. ews_expression.php too. I dont know what to do. – Xymz Mar 23 '15 at 10:44
  • You should do some debugging yourself next time, and please -this is important- , add extra information to your question! You still have the not-specific error in your question. Comments are not the place! I'll debug it a bit more and come up with an answer for you I hope. – Nanne Mar 23 '15 at 11:38

1 Answers1

0

You have an issue with your autoloader. The default files of that library are loaded like this:

$pfad=SCRIPT_DIR."include/php-ews";
$include_file = $pfad . '/' . str_replace('_', '/', $className) . '.php';

If your autoloader is the first to try and load that exception, it will replace the '_'. If you put an error_log in that autoloader function you will probably see the result of $inlcude_file to be something like

include/php-ews/EWS/Exception

And that file doesn't exist.

So you should fix your autoloader so it can actually find the file.

To be aboslutely clear:

  • you (the code) are looking for the class EWS_Exception
  • this is in the file EWS_Exception.php (in the root of the project)
  • your autoloader cannot find that file as you replace all _

so the sollution is to either fix your autoloader, or just include that EWS_Exception.php file somewhere.

Nanne
  • 64,065
  • 16
  • 119
  • 163
  • I dont have ../../EWS/Exception. the only file i have with that name is EWS_Exception. BUT this file only load the class from the file Exception. But i dont have this file. Even when i download the zip from the site there is no file named Exception – Xymz Mar 23 '15 at 12:46
  • I know you don't have that file. That's the whole problem. The file is not located in the same way all other files are. Either fix that, or fix your autoloader. The default `Exception` it extends from is in PHP, you'll have that. – Nanne Mar 23 '15 at 13:09
  • ah okay now it work thanks for your´e help. But now i get everytime i start the script the error message at my screen "Not collected Exception: Wrong Version". I set the version to Exchange 2010. What´s wrong ? you may have any idea? – Xymz Mar 23 '15 at 14:16