修改
我决定彻底改变我对你们的看法。我使用亚马逊提供的脚本连接到Alexa API并获取一些信息。我在我的数据库中有一个表,我从(通过URL)中提取行并使用此脚本尝试使用此收集的信息更新当前为空的列。
以下示例显示了我为http://google.com
获得的结果我希望我已经说明了这一点,并且避免让人感到困惑。
以下代码:
public static function parseResponse($response) {
$xml = new SimpleXMLElement($response,null,false,
'http://awis.amazonaws.com/doc/2005-07-11');
if($xml->count() && $xml->Response->UrlInfoResult->Alexa->count()) {
$info = $xml->Response->UrlInfoResult->Alexa;
$nice_array = array(
'Phone Number' => $info->ContactInfo->PhoneNumbers->PhoneNumber,
'Owner Name' => $info->ContactInfo->OwnerName,
'Email' => $info->ContactInfo->Email,
'Street' => $info->ContactInfo->PhysicalAddress->Streets->Street,
'City' => $info->ContactInfo->PhysicalAddress->City,
'State' => $info->ContactInfo->PhysicalAddress->State,
'Postal Code' => $info->ContactInfo->PhysicalAddress->PostalCode,
'Country' => $info->ContactInfo->PhysicalAddress->Country,
'Links In Count' => $info->ContentData->LinksInCount,
'Rank' => $info->TrafficData->Rank
);
}
echo '<pre>';
print_r(array_values($nice_array));
echo '</pre>';
}
将输出:
Array
(
[0] => SimpleXMLElement Object
(
[0] => unlisted
)
[1] => SimpleXMLElement Object
(
[0] => aa
)
[2] => SimpleXMLElement Object
(
[0] => dns-admin@google.com
)
[3] => SimpleXMLElement Object
(
[0] => aa
)
[4] => SimpleXMLElement Object
(
[0] => unlisted
)
[5] => SimpleXMLElement Object
(
[0] => unlisted
)
[6] => SimpleXMLElement Object
(
[0] => unlisted
)
[7] => SimpleXMLElement Object
(
[0] => unlisted
)
[8] => SimpleXMLElement Object
(
[0] => 3555997
)
[9] => SimpleXMLElement Object
(
[0] => 1
)
)
正如您所看到的,每个&#34;对象&#34;对应上面的代码,分别显示电话号码,所有者姓名,电子邮件,街道,城市,州,邮政编码,国家,计数链接和排名。
我需要做的是获取每个值并更新数据库中的那一行。