我有输出网站排名的课程
$urlInfo->getUrlInfo();
这是用于排名的 alexa amazon aws。out 将是域的排名。我需要将等级插入数据库,但除非我将其设置为变量,否则我不能。
我能做些什么?
我试过了:
mysql_query("INSERT INTO rank (date, domain, rank) VALUES ('$date','$domain','".$urlInfo->getUrlInfo()."')")
但等级为空。
这就是 geturlinfo 函数的样子
public function getUrlInfo() {
$queryParams = $this->buildQueryParams();
$sig = $this->generateSignature($queryParams);
$url = 'http://' . self::$ServiceHost . '/?' . $queryParams .
'&Signature=' . $sig;
$ret = self::makeRequest($url);
//echo "\nResults for " . $this->site .":\n\n <br>";
self::parseResponse($ret);
}
然后脚本将函数的数组定义为结果
public static function parseResponse($response) {
$xml = new SimpleXMLElement($response,null,false,
'http://awis.amazonaws.com/doc/2005-07-11');
if($xml->count() && $xml->Response->TrafficHistoryResult->Alexa->count()) {
$info = $xml->Response->TrafficHistoryResult->Alexa;
$nice_array = array(
// '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,
// 'Usage' => $info->TrafficData->UsageStatistics
'Rank' => $info->TrafficHistory->HistoricalData->Data->Rank
);
}
foreach($nice_array as $k => $v)
{
echo $k.': ' . $v ."\n <br>";
}
}
更新:这有效。我现在可以把它放在一个 href=XX 但仍然更新到 mysql 显示空白
$accessKeyId1 = "XXX";
$secretAccessKey1 = "XXX";
$site1 = $_GET['domain'];
$StartNum1 = $_GET['currentdate'];
//$url = $urlInfo->getUrlInfo();
//echo "URL : ".$url;
function Rank($accessKeyId, $secretAccessKey, $site, $StartNum)
{$urlInfo = new UrlInfo($accessKeyId, $secretAccessKey, $site, $StartNum); $urlInfo->getUrlInfo();}
echo "test url:<a href='/";
$test = Rank($accessKeyId1, $secretAccessKey1, $site1, $StartNum1);
//$testing = mysql_query("UPDATE rank SET rank = '".Rank($accessKeyId1, $secretAccessKey1, $site1, $StartNum1)."' WHERE domain = '4shared.com'") or die(mysql_error());
echo $test."'>test</a>";
对于 UPDATE 我尝试了 Rank($accessKeyId1, $secretAccessKey1, $site1, $StartNum1) 和 $test.
有什么想法吗?