我正在尝试从谷歌联系人中获取联系人的名字,但是一直没成功。不过,我可以顺利提取电子邮件地址。有人能告诉我我哪里做错了吗?
$xmlresponse=file_get_contents('https://www.google.com/m8/feeds/contacts/default/full?oauth_token='.$accesstoken);
//reading xml using SimpleXML
$xml= new SimpleXMLElement($xmlresponse);
$xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
$nameFirst = $xml->xpath('//gd:givenName'); // I have also tried //gd:name
$result = $xml->xpath('//gd:email');
foreach($nameFirst as $nameF){
echo $nameF->getName();
}
foreach ($result as $title) {
echo $title->attributes()->address . "<br>";
}
?>