目前我正在使用一段代码从谷歌帐户获取谷歌联系人电子邮件并将它们显示到表格中。电子邮件正确显示,但我也希望显示此人的姓名。我目前使用的代码如下。我知道 $xml 包含名称(我尝试在 html 上打印出来),但我不知道如何显示它。$result 不再包含名称,所以我猜测显示的名称必须在此之前。有人有什么主意吗?
//passing accesstoken to obtain contact details
$xmlresponse = file_get_contents('https://www.google.com/m8/feeds/contacts/default/full?oauth_token='.$tok_value.'&max-results=500');
//print_r($xmlresponse);
//reading xml using SimpleXML
$xml = new SimpleXMLElement($xmlresponse);
//print_r($xml);
$xml->registerXPathNamespace('gd', 'http://schemas.google.com/g/2005');
//after dumping there is no names in the result
$result = $xml->xpath('//gd:email');
//var_dump($result);
$count = 0;
echo "<table class=\"inv-table\" cellpadding=\"5\">";
foreach ($result as $title)
{
//echo $title->attributes()->address . "<br><br>";
echo "<tr><td><input type=\"checkbox\"
name=\"email_to[]\"
value=".$title->attributes()->address.">".$title->attributes()->address;
echo "</td></tr>";
//echo $title->attributes()->displayName;
//echo $title->fullName;
$count = $count + 1;
}
echo "</table>";
提前致谢!