我正在使用这个脚本来找出当天的每日访问者和总浏览量。
<?xml version="1.0" ?>
- <aws:UrlInfoResponse xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/">
- <aws:Response xmlns:aws="http://awis.amazonaws.com/doc/2005-07-11">
- <aws:UrlInfoResult>
- <aws:Alexa>
- <aws:TrafficData>
- <aws:UsageStatistic>
- <aws:TimeRange>
<aws:Months>1</aws:Months>
</aws:TimeRange>
- <aws:Rank>
<aws:Value>2426210</aws:Value>
<aws:Delta>-12536204</aws:Delta>
</aws:Rank>
- <aws:Reach>
- <aws:Rank>
<aws:Value>2757065</aws:Value>
<aws:Delta>-12015838</aws:Delta>
</aws:Rank>
- <aws:PerMillion>
<aws:Value>0.4</aws:Value>
<aws:Delta>+1200%</aws:Delta>
</aws:PerMillion>
</aws:Reach>
- <aws:PageViews>
- <aws:PerMillion>
<aws:Value>0.21</aws:Value>
<aws:Delta>+4000%</aws:Delta>
</aws:PerMillion>
- <aws:Rank>
<aws:Value>2206561</aws:Value>
<aws:Delta>-12826154</aws:Delta>
</aws:Rank>
- <aws:PerUser>
<aws:Value>3</aws:Value>
<aws:Delta>+200%</aws:Delta>
</aws:PerUser>
</aws:PageViews>
</aws:UsageStatistic>
</aws:UsageStatistics>
<aws:ContributingSubdomains />
</aws:TrafficData>
</aws:Alexa>
</aws:UrlInfoResult>
- <aws:ResponseStatus xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/">
<aws:StatusCode>Success</aws:StatusCode>
</aws:ResponseStatus>
</aws:Response>
</aws:UrlInfoResponse>
该文件保存在服务器的某个位置。
使用此代码获取
$xml = simplexml_load_file("PATH To FILE", null, null, 'aws', true);
$pageview=$income_data->Response->UrlInfoResult->Alexa->TrafficData->UsageStatistics->UsageStatistic->PageViews->PerMillion->Value;
$daily_pageview=$pageview*10;
一切都很好,直到我发现结果对于少数域值都不正确。然后我尝试回显每个值,我发现它忽略了点之后的值(。)
[Like for example]
.02=>0
.100=>0
1.02=>1
在上述情况下,值$pageview=0.21
和输出是0
但它应该来2.1
。
对此的任何帮助将不胜感激..