我正在尝试使用Outlook.com API在我的Outlook.com帐户上创建联系人,但他们没有来自php的示例。我假设您必须使用PHP的REST API调用?
显然,格式为:
GET https://apis.live.net/v5.0/contact.de3413e6000000000000000000000000?access_token=ACCESS_TOKEN
使用REST示例编写联系人如下所示:
POST https://apis.live.net/v5.0/me/contacts
Authorization: Bearer ACCESS_TOKEN
Content-Type: application/json
{
"first_name": "Roberto",
"last_name": "Tamburello"
}
我对如何把它变成php格式感到困惑。也许,您应该使用cURL命令?
答案 0 :(得分:1)
最简单的方法是使用cUrl来调用API。这应该可以帮助您入门。
GET:
<?php
$access_token = "TOKEN";
$api_url = 'https://apis.live.net/v5.0/contact.de3413e6000000000000000000000000?access_token='.$access_token;
$curl = curl_init($api_url);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = json_decode(curl_exec($curl));
curl_close($curl);
POST:
<?php
$access_token = "TOKEN";
$api_url = "https://apis.live.net/v5.0/me/contacts";
$curl = curl_init($api_url);
$curl_data = array(
'first_name' => "Roberto",
'last_name' => "Tamburello"
);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_data);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$curl_response = curl_exec($curl);
var_dump($curl_response);