編集:
これを皆さんに伝える方法を完全に変更することにしました。Amazon が提供するスクリプトを使用して、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
)
)
ご覧のとおり、これらの「オブジェクト」はそれぞれ上記のコードに対応し、電話番号、所有者名、電子メール、番地、都市、州、郵便番号、国、リンク数、およびランクをそれぞれ示しています。
私がする必要があるのは、各値を取得して、データベース内のその行を更新することです。