我從辦公室365構建了一個簡單的聯繫簿,列出了我公司的所有共享聯繫人。 我也在嘗試使用Graph和EWS,但我無法弄清楚什麼是錯的。從PHP EWS office365獲取所有公共文件夾/共享聯繫人
搜索Microsoft Graph explorer似乎沒有機會看到我的「其他聯繫人」 - >「所有聯繫人」文件夾。 我一直在嘗試使用「/ me/contactFolders」端點和「/ people」端點。非他們給了我結果。
我還使用了一個php-ews庫(該項目建立在Laravel上)通過Exchange訪問文件夾,但沒有運氣。 使用this example,我只能列出我的聯繫人,沒有任何機會看到其他文件夾或其他類型的聯繫人。
有沒有人有任何提示newbbie?
在此先感謝。 編輯 這是一個用PHP-EWS庫工作控制器
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use garethp\ews\ContactsAPI as ContactsAPI;
use garethp\ews\API;
use garethp\ews\API\Enumeration;
use garethp\ews\API\Type;
use garethp\ews\API\ExchangeWebServices;
//use garethp\ews\API\ExchangeAutodiscover;
//use garethp\ews\API\Exception\AutodiscoverFailed;
class SharedContatctsController extends Controller
{
//
public function index()
{
# code...
$mail='[email protected]';
$pwd='password';
$version='Exchange2016';
//$apiS = ExchangeAutodiscover::getAPI($mail, $pwd);
//$server=$apiS->getClient()->getServer();
$server='mail.example.com;
$api = ContactsAPI::withUsernameAndPassword($server, $mail, $pwd);
$contacts = $api->getContacts();
//return print($api->getFolderId());
//If you want to get contacts within a folder
//$folder = $api->getFolderByDisplayName('Altri Contatti', 'contacts');
//$contacts = $api->getContacts($folder->getFolderId());
return view('shared',array('contacts'=>$contacts,'displayName'=>$contacts['displayName']));
}
}
這是(相當有效)顯示「BackupContacts」文件夾是在同一目錄「接觸」
控制器<?php
namespace App\Http\Controllers;
use Microsoft\Graph\Graph;
use Microsoft\Graph\Model;
use App\Http\Controllers\Controller;
class OutlookController extends Controller
{
public function contacts()
{
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
$tokenCache = new \App\TokenStore\TokenCache;
$graph = new Graph();
$graph->setAccessToken($tokenCache->getAccessToken());
$user = $graph->createRequest('GET', '/me')
->setReturnType(Model\User::class)
->execute();
$contactsQueryParams = array (
// // Only return givenName, surname, and emailAddresses fields
//"\$select" => "displayName,scoredEmailAddresses",
// Sort by given name
//"\$orderby" => "givenName ASC",
// Return at most 10 results
"\$orderby"=>"displayName",
"\$top" => "1000"
);
$getContactsUrl = '/me/contactFolders/{BackuPlderId-retrieved-with-Graph}/contacts/?'.http_build_query($contactsQueryParams);
$contacts = $graph->createRequest('GET', $getContactsUrl)
->addHeaders(array ('X-AnchorMailbox' => $user->getMail()))
->setReturnType(Model\Contact::class)
->execute();
return view('contacts', array(
'username' => $user->getdisplayName(),
'usermail' => $user->getMail(),
'contacts' => $contacts
));
}
}
我們總是樂於幫助和支持新的編碼器,但是您需要首先幫助自己。 : - )***在[**做更多研究**之後](https://meta.stackoverflow.com/q/261592/1011527)如果你有問題**發佈你已經嘗試** **清楚說明什麼不工作**並提供[最小,完整和可驗證示例](http://stackoverflow.com/help/mcve)。閱讀[如何問](http://stackoverflow.com/help/how-to-ask)一個很好的問題。請務必[參觀](http://stackoverflow.com/tour)並閱讀[this](https://meta.stackoverflow.com/q/347937/1011527)。 –
對不起@JayBlanchard。只是編輯,使其更清晰。 – Biro