2016-05-22 80 views
0

下載PHP-EWS,做了取得PHP-EWS從<a href="https://github.com/Garethp/php-ews" rel="nofollow">https://github.com/Garethp/php-ews</a>工作

  require_once ($server_path."/scripts/ews/API.php"); 

這似乎工作(日誌沒有給出錯誤)。

但是這樣做:

  $ews = ExchangeWebServices::fromUsernameAndPassword($exchange_host, $_SESSION["user_data"]["u_email"], $_SESSION["user_data"]["u_pwd"], $options = array()); 

給人

PHP Fatal error: Class 'ExchangeWebServices' not found 

任何一個有想法?

回答

2

嗯,我想建議你嘗試使用Composer安裝我的庫。你可以download it here。然後,一旦安裝,您可以使用它來安裝我的庫。只要創建一個composer.json文件具有以下

{ 
    "require": { 
     "garethp/php-ews": "0.8.*" 
    } 
} 

然後在目錄中運行一個composer install。這應該創建一個vendor/autoload.php文件的vendor/文件夾。包括這個文件,其餘的類應該自動加載

+0

好吧,我試過..作曲,似乎它的作品(當然,它;-)) 但我仍然得到這個: **(mod_fastcgi.c.2695)FastCGI-stderr:PHP致命錯誤:在' – osomanden

+0

'中找不到'ExchangeWebServices'類,並且自動加載器似乎工作。或至少當我刪除路徑的一部分失敗響並清楚地;-) – osomanden

+1

'code'echo 「

"; print_r(get_declared_classes()); echo "
」;'code' 給出[372] => ComposerAutoloaderInitbc25b4c7c627f48ed3a0f739e38bad53 [373] =>作曲\自動加載\類加載器 [374] => Composer \ Autoload \ ComposerStaticInitbc25b4c7c627f48ed3a0f739e38bad53但沒有ews類(API或ExchangeWebServices) – osomanden

1

通過取消我的檢查,如果交換選項是有效的,它的工作。

移除

if ($core_row["exchange_active"] == 1) { 

其被包圍API調用。

require 'scripts/ews/vendor/autoload.php'; 

$exchange_host = $core_row["exchange_host"].":".$core_row["exchange_port"]; 
$version = "Exchange2013"; // to be optional in core_data 
//Create and build the client 
use garethp\ews\API; 
$ews = API::withUsernameAndPassword($exchange_host, $_SESSION["user_data"]["u_email"], $_SESSION["user_data"]["u_pwd"], $version); 

瘋狂我一天一點光明..

結果

echo "<pre>"; print_r(get_declared_classes()); echo "</pre>"; 
...... 

[358] => ComposerAutoloaderInitbc25b4c7c627f48ed3a0f739e38bad53 
[359] => Composer\Autoload\ClassLoader 
[360] => Composer\Autoload\ComposerStaticInitbc25b4c7c627f48ed3a0f739e38bad53 
[361] => garethp\ews\API 
[362] => garethp\ews\API\ExchangeWebServices 
[363] => garethp\ews\API\ExchangeWebServicesAuth 
[364] => garethp\ews\API\ClassMap 
[365] => garethp\ews\API\NTLMSoapClient 
[366] => garethp\ews\HttpPlayback\HttpPlayback 
+1

只是FYI:改爲使用'require_once'是一種很好的做法,除此之外沒有其他任何東西,並且所有的'使用'陳述都在其下。 「使用」陳述應該放在任何和所有邏輯之前 –

相關問題