如何使用api for php在office365中添加联系人


How to add contact in office365 using api for php

我想问一些关于Office365 CRM的问题,使用此CRM我获得了访问令牌,但不幸的是,如何使用该访问令牌添加联系人和获取联系人详细信息。当我试图将联系人添加到CRM中时,我收到了类似401 Http请求的错误。而且我也不知道发送给CRM的请求的头字段和有效载荷格式。

https://msdn.microsoft.com/office/office365/APi/contacts-rest-operations#GetContacts这是用于获取访问代码、用户邮件地址的链接。您已获得用于创建联系人的access_token和用户邮件地址。

public static function createcontact($access_token, $user_email) {
    $email = array (
            "Address" => "sample.onmicrosoft.com",
            "Name" => "kkkkk" 
    );
    $email_value = json_encode ( $email );
    $getContactsParameters = array (
            "GivenName" => "sample",
            "Surname" => "xxxxxxx",
            "BusinessPhones" => array (
                    "+00000000" 
            ) 
    );
    $data_string = json_encode ( $getContactsParameters );
    $getContactsUrl = self::$outlookApiUrl . "/Me/Contacts?";
    return self::makeApiCall ( $access_token, $user_email, "POST", $getContactsUrl, $data_string );
}

您必须设置范围、设置url和设置主体才能创建联系人

范围:https://outlook.office.com/contacts.readwrite

网址:https://api.office.com/discovery/v2.0/me/