我在 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
变量实际上是空的。是否可以安全地假设这个库已损坏或者我在设置上做错了什么?您能否推荐任何其他可以做同样事情的图书馆,或者可能会指出一些资源,可以帮助我编写自己的图书馆以登录亚马逊附属网站并获取一些报告。
提前致谢!