如何从Amazon Affiliate获取报告

时间:2013-06-27 07:56:09

标签: php report amazon php-oara

我在Github找到了这个PHP-Oara库https://github.com/fubralimited/php-oara,我已经设置了所有内容。

$networkName = "Amazon"; //Ex: AffiliateWindow
//Retrieving the credentials for the network
$config = Zend_Registry::getInstance()->get('credentialsIni');

$configName = strtolower($networkName);
$credentials = $config->$configName->toArray();

//Path for the cookie located inside the Oara/data/curl folder
$credentials["cookiesDir"] = "example";
$credentials["cookiesSubDir"] = $networkName;
$credentials["cookieName"] = "test";

//The name of the network, It should be the same that the class inside Oara/Network
$credentials['networkName'] = $networkName;
//Which point of view "Publisher" or "Advertiser"
$credentials['type'] = "Publisher";
//The Factory creates the object

$network = Oara_Factory::createInstance($credentials);

我还在credentials.ini文件中添加了必要的详细信息:

;------------Amazon (All the newtwork are available)------------

;The user name used in Amazon associates to log in
amazon.user = 'my amazon affiliate email'

;The password used in Amazon associates to log in
amazon.password = 'my amazon affiliate password'

;Network we are going to log in: uk, es, us, ca, de, fr, it, jp, cn.
amazon.network = 'us'

但我收到以下错误:

Failed to find log in form!

我认为这只是登录表单的名称:

if (!preg_match('/<form name="signIn".*?<\/form>/is', $page, $form)) {
    die('Failed to find log in form!');
}

由于https://affiliate-program.amazon.com中的名称实际上是sign_in,但当我将其更改为该名称时,它没有任何效果。

但真正的问题是$page变量实际上是空的。 假设这个库被破坏或者我是否对设置做错了是否安全? 你能推荐任何其他可以做同样事情的图书馆,或者可能会给我一些资源,这些资源可以帮助我编写我自己的图书馆,登录亚马逊联盟网站并获取一些报告。

提前致谢!

1 个答案:

答案 0 :(得分:1)

我使用此库,但我不使用credentials.ini,因为我拥有数据库中的所有凭据。

所以我更改了示例/ generic.php以编程方式添加凭据:

$email = ...;
$password = ...;
$network = ...;
$networkName = "Amazon";
$networkType = "Publisher";


$credentials = array();

//Path for the cookie located inside the Oara/data/curl folder
$credentials["cookiesDir"] = "example";
$credentials["cookiesSubDir"] = $networkName;
$credentials["cookieName"] = "test";

$credentials["user"] = $email;
$credentials["password"] = $password;
$credentials["network"] = $network;
$credentials['networkName'] = $networkName;
$credentials['type'] = $networkType;

//The Factory creates the object
$network = Oara_Factory::createInstance($credentials);
Oara_Test::testNetwork($network);

我可以登录并访问亚马逊数据。也许既然你已经写过这篇文章,那么对图书馆进行了一些更新。我可以说它现在有用了。

我得到的结果是:

Total Number of payments: XX

Number of merchants: XX


importing from 01-08-2013 00:00:00 to 31-08-2013 23:59:59
Number of transactions: XX

Number register on the overview: XX


importing from 01-09-2013 00:00:00 to 30-09-2013 23:59:59
Number of transactions: XX

Number register on the overview: XX


importing from 01-10-2013 00:00:00 to 05-10-2013 23:59:59
Number of transactions: XX

Number register on the overview: XX

Import finished