나는 내 회사의 모든 공유 연락처를 나열하는 office 365의 간단한 연락처 북을 만들고 있습니다. 그래프와 EWS도 시도했지만, 무엇이 잘못되었는지 알 수 없습니다.PHP를 사용하는 EWS office365의 모든 공용 폴더/공유 연락처 가져 오기
Microsoft Graph explorer에서 검색하면 내 "기타 연락처"-> "모든 연락처"폴더를 볼 기회가없는 것 같습니다. "/ me/contactFolders"엔드 포인트와 "/ people"엔드 포인트로 시도했습니다. 그들 중 누구도 나에게 결과를주지 않았다.
php-ews 라이브러리 (프로젝트는 Laravel에서 빌드 됨)를 사용하여 Exchange를 통해 폴더에 액세스 할 수 있습니다. this example을 사용하면 다른 연락처 나 다른 종류의 연락처를 볼 기회가 없어도 내 연락처 만 표시 할 수 있습니다.
누구나 초보자를위한 팁이 있습니까?!
미리 감사드립니다. 편집 이 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) 문제가 있다면 ** 당신이 시도한 것을 게시하십시오 ** ** 작동하지 않는 것에 대한 명확한 설명 ** 및 [Minimal, Complete, Verifiable example] (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