我已经开始从现场导入联系人。现在我不知道 MS 在想什么,但他们确实把他们手上的一切都复杂化了。
对于我的应用程序,获得电话号码非常重要。事实上如此重要,如果您没有电话号码,您的联系人将被跳过。用我的方法,我看不到任何电话号码。我以为如果我一个接一个地遍历每个联系人,它就会显示出来,但是,唉,没有爱。
这是我的方法:
$import_id = time();
$client_id = "xxx";
$redirect_uri = 'redirecturi';
$client_secret = "xxx";
$code = $_GET['code'];
$grant_type = "authorization_code";
$post = "client_id=$client_id&redirect_uri=$redirect_uri&client_secret=$client_secret&code=$code&grant_type=$grant_type";
$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,false);
$result = curl_exec($curl);
curl_close($curl);
$token = json_decode($result);
$access_token = $token->access_token;
$user_id = $token->user_id;
$url = "https://apis.live.net/v5.0/me/contacts?access_token=$access_token";
$response = curl_file_get_contents($url);
$response = json_decode($response);
foreach($response->data as $contact) {
$contact_details = curl_file_get_contents("https://apis.live.net/v5.0/" . $contact->id . "?access_token=$access_token");
debug($contact_details);
}
die();
但是,我只能这样获取信息(我认识的这个人有一个联系电话,当我在 people.live.com 上查看他时可以看到):
{
"id": "contact.id",
"first_name": "Danie",
"last_name": "Van den Heever",
"name": "Danie Van den Heever",
"is_friend": false,
"is_favorite": false,
"user_id": "userid",
"email_hashes": [
"emailhash"
],
"updated_time": "2014-09-17T12:11:10+0000"
}
我的权限请求 url(定义范围)如下所示:
https://login.live.com/oauth20_authorize.srf?client_id=clientidkey&scope=wl.basic%20wl.offline_access&response_type=code&redirect_uri=redirecturi
我应该添加更多范围以获取联系电话吗?如果是这样,哪些范围?或者这是不可能的?