2013-06-27 55 views
2

我在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

我使用這個庫,但我不使用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