我使用了 keepa api ,并且还运行了
这样的composer命令 composer require keepa/php_api:*
但仍低于显示错误
的错误致命错误:未捕获的错误:找不到类'Keepa \ KeepaAPI' /home/sysadmin/share/magento/keepaapi/php_api/index.php:15堆栈 跟踪:抛出#0 {main} /home/sysadmin/share/magento/keepaapi/php_api/index.php,第15行
和我的根目录文件夹结构
下面是发生错误时的代码
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
use Keepa\API\Request;
use Keepa\API\ResponseStatus;
use Keepa\helper\CSVType;
use Keepa\helper\CSVTypeWrapper;
use Keepa\helper\KeepaTime;
use Keepa\helper\ProductAnalyzer;
use Keepa\helper\ProductType;
use Keepa\KeepaAPI;
use Keepa\objects\AmazonLocale;
$api = new KeepaAPI("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
$r = Request::getProductRequest(AmazonLocale::DE, 0, "2015-12-31", "2018-01-01", 0, true, ['B001G73S50']);
$response = $api->sendRequestWithRetry($r);
switch ($response->status) {
case ResponseStatus::OK:
// iterate over received product information
foreach ($response->products as $product){
if ($product->productType == ProductType::STANDARD || $product->productType == ProductType::DOWNLOADABLE) {
//get basic data of product and print to stdout
$currentAmazonPrice = ProductAnalyzer::getLast($product->csv[CSVType::AMAZON], CSVTypeWrapper::getCSVTypeFromIndex(CSVType::AMAZON));
//check if the product is in stock -1 -> out of stock
if ($currentAmazonPrice == -1) {
echo sprintf("%s %s is currently not sold by Amazon (out of stock) %s",$product->asin,$product->title,PHP_EOL);
} else {
echo sprintf("%s %s Current Amazon Price: %s %s",$product->asin,$product->title,$currentAmazonPrice,PHP_EOL);
}
// get weighted mean of the last 90 days for Amazon
$weightedMean90days = ProductAnalyzer::calcWeightedMean($product->csv[CSVType::AMAZON], KeepaTime::nowMinutes(),90, CSVTypeWrapper::getCSVTypeFromIndex(CSVType::AMAZON));
} else {
}
}
break;
default:
print_r($response);
}