我已经开始从实时导入联系人。现在我不知道微软在想什么,但他们真的把他们所做的一切都搞得太复杂了。
对于我的应用程序来说,获取电话号码非常重要。事实上,非常重要的是,如果您没有电话号码,您的联系方式将被跳过。用我的方法我看不到任何电话号码。我以为如果我一一循环每个联系人就会显示出来,但是可惜,没有爱。
这是我的方法:
$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
我应该添加更多范围来获取联系号码吗?如果有,范围是哪些?或者这是不可能的?