我使用了WooCommerce API和以下代码:
<?php
set_time_limit(0);
// Include the client library
require_once \'class-wc-api-client.php\';
$consumer_key = \'XXXX\'; // Add your own Consumer Key here
$consumer_secret = \'XXXX\'; // Add your own Consumer Secret here
$store_url = \'http://www.example.com/\'; // Add the home URL to the store you want to connect to here
// Initialize the class
$wc_api = new WC_API_Client( $consumer_key, $consumer_secret, $store_url );
$file = \'./dataX.txt\';
if (file_exists($file) ) {
$products = file_get_contents($file);
}
else {
$itemsPerPage = 15;
$page = 0;
$p = $wc_api->get_products(array( \'filter[limit]\' => $itemsPerPage, \'filter[offset]\' => ($page * $itemsPerPage) ) );
$products = array();
while (!empty($p->products)) {
foreach ($p->products as $pppp) {
$products[] = $pppp;
}
$page++;
$p = $wc_api->get_products(array( \'filter[limit]\' => $itemsPerPage, \'filter[offset]\' => ($page * $itemsPerPage) ) );
}
print \'<pre>\';
print sizeof($products).\'----\';
print_r($products);
die();