Created
February 27, 2009 17:31
-
-
Save riaf/71584 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if(!class_exists('Rhaco')) require_once 'rhaco/Rhaco.php'; | |
Rhaco::import('network.http.Browser'); | |
class AmazonReport | |
{ | |
var $base_url = 'https://affiliate.amazon.co.jp'; | |
var $browser; | |
function AmazonReport($email, $password){ | |
$this->login($email, $password); | |
} | |
function login($email, $password){ | |
$browser = new Browser(); | |
$browser->get($this->base_url . '/gp/associates/login/login.html'); | |
$browser->setVariable('email', $email); | |
$browser->setVariable('password', $password); | |
$browser->submit('sign-in'); | |
return $this->browser =& $browser; | |
} | |
function getData($param = array()){ | |
return $this->parseXml($this->getXml($param)); | |
} | |
function parseXml($xml){ | |
$tag = new SimpleTag(); | |
$tag->set($xml, 'Data'); | |
return $tag->toHash(); | |
} | |
function getXml($param = array()){ | |
$this->browser->clearVariable(); | |
list($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); | |
$param_default = array( | |
'ie' => 'UTF8', | |
'reportType' => 'ordersReport', | |
'periodType' => 'exact', | |
'startMonth' => '1', | |
'startDat' => '1', | |
'startYear' => '2002', | |
'endMonth' => $mon + 1, | |
'endDay' => $mday, | |
'endYear' => $year + 1900, | |
); | |
foreach($param as $k => $v){ | |
$param_default[$k] = $v; | |
} | |
$url = $this->base_url . '/network/reports/report.html/?' . http_build_query($param_default) . '&submit.download_XML'; | |
return $this->browser->get($url); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment