Php Outlook REST API未返回其应返回的所有数据

Php Outlook REST API未返回其应返回的所有数据,php,rest,outlook,Php,Rest,Outlook,情况: 我正在尝试返回Hotmail联系人的信息。我正在使用我想要和需要的所有作用域,请参见此处(Index.php:$url):wl.signin+wl.basic+wl.emails+wl.contacts\u emails+wl.birth+wl.postal\u address+wl.phone\u number但真正起作用的只有wl.signin+wl.basic+wl.emails+wl.contacts\u emails。不工作的不会返回任何内容,甚至不会返回空值 问题: 如何让a


情况:
我正在尝试返回Hotmail联系人的信息。我正在使用我想要和需要的所有作用域,请参见此处(Index.php:$url):
wl.signin+wl.basic+wl.emails+wl.contacts\u emails+wl.birth+wl.postal\u address+wl.phone\u number


但真正起作用的只有
wl.signin+wl.basic+wl.emails+wl.contacts\u emails
。不工作的不会返回任何内容,甚至不会返回空值

问题:
如何让api返回联系人的邮政地址、电话号码和生日,而不仅仅是姓名和电子邮件

额外的:

  • 我用来获取联系人的帐户是一个测试帐户 我手动添加的一个联系人
  • 是不是因为我和联系人不是朋友
  • 现在我正在使用一个简单的
    echo
    来查看
    $xmlresponse
    包含
这是api返回的结果:

{
   "data": [
      {
         "id": "contact.eefb1331000000000000000000000000", 
         "first_name": "Mike", 
         "last_name": "Lammers", 
         "name": "Mike Lammers", 
         "is_friend": false, 
         "is_favorite": false, 
         "user_id": null, 
         "email_hashes": [
            "f981031f06db7ae6f6dabdd368785eece037ba13f4b3f99ff702d950fa1561e9", 
            "f047784aa8b6bfb8895a06739741f2733b80371e8e88a10b33dfdee5214c7a7b", 
            "b1edf3ecd7c0669a01a6539b965e88aebe1d20ceef578f8699b8cb4355e02626"
         ], 
         "updated_time": "2016-03-10T08:31:48+0000", 
         "emails": {
            "preferred": "persoonlijk@gmail.com", 
            "account": null, 
            "personal": "persoonlijk@gmail.com", 
            "business": "werk@gmail.com", 
            "other": "overig@gmail.com"
         }
      }
   ], 
   "paging": {

   }
}
oauth-hotmail.php

<?php

//function for parsing the curl request
function curl_file_get_contents($url) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
    curl_setopt($ch, CURLOPT_HEADER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
}
$client_id = 'xxxxx';
$client_secret = 'xxxxxxx';
$redirect_uri = 'http://localhost:11080/oauth-hotmail.php';
$auth_code = $_GET["code"];

$fields=array(
    'code'=>  urlencode($auth_code),
    'client_id'=>  urlencode($client_id),
    'client_secret'=>  urlencode($client_secret),
    'redirect_uri'=>  urlencode($redirect_uri),
    'grant_type'=>  urlencode('authorization_code')
);

$post = '';

foreach($fields as $key=>$value) { $post .= $key.'='.$value.'&'; }
$post = rtrim($post,'&');
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,'https://login.live.com/oauth20_token.srf');
curl_setopt($curl,CURLOPT_POST,5);
curl_setopt($curl,CURLOPT_POSTFIELDS,$post);
curl_setopt($curl, CURLOPT_RETURNTRANSFER,TRUE);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER,0);
$result = curl_exec($curl);
curl_close($curl);
echo $contents ;

$response =  json_decode($result);
$accesstoken = $response->access_token;
//$accesstoken = $_SESSION['accesstoken'] ;//= $_GET['access_token'];
$url = 'https://apis.live.net/v5.0/me/contacts?access_token='.$accesstoken.'&limit=500';
$xmlresponse =  curl_file_get_contents($url);
$contacts = json_decode($xmlresponse, true);
$return = array();

$hotmail_contacts = $return;
$hotmail_json = json_encode($return);

echo '<br><br><pre>';
echo $xmlresponse;
echo '</pre><br><br>';

?>

index.php


将所有不起作用的作用域更改为wl.contacts\u0。。。。。见下文

范围=wl.signin+wl.basic+wl.emails+wl.contacts\u emails+wl.contacts\u Birth+wl.contacts\u postal\u addresses+wl.contacts\u电话号码

这是因为在使用scope时,您只能访问自己的详细信息,而不能访问联系人列表中的联系人

<?php
session_start();
$client_id = 'xxxx';
$client_secret = 'xxxx';
$redirect_uri = 'http://localhost:11080/oauth-hotmail.php';

$urls_ = 'https://login.live.com/oauth20_authorize.srf?client_id='.$client_id.'&scope=wl.signin+wl.basic+wl.emails+wl.contacts_emails+wl.birthday+wl.postal_addresses+wl.phone_numbers
&response_type=code&redirect_uri='.$redirect_uri;

?>
<!DOCTYPE>
<html>

<body>
<?php echo '<a href="'.$urls_.'">Contact From MSN</a>';?>


</body>
</html>