当我试图通过bigcommerce api连接到我的bigcommerce帐户时,我遇到了一个问题.根据这个网址,我遵循了以下指导方针:
但这对我没有用。它显示出以下警告
警告:为第16行的C:\wamp\www\bigcommerce\index.php中的foreach()提供的无效参数
然后,我遵循了以下步骤:
并试图执行以下代码..。
<?php
require 'bigcommerce-api-php-master/bigcommerce.php';
use Bigcommerce\Api\Client as Bigcommerce;
Bigcommerce::configure(array(
'store_url' => 'https://store-atka90u.mybigcommerce.com/api/v2/',
'username' => 'admin',
'api_key' => '4581223546f2bf73840d84b4802cab039f249404'
));
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
$products = Bigcommerce::getProducts();
foreach($products as $product) {
echo $product->name;
echo $product->price;
}
?>但它再次显示同样的警告,即使在我添加了2个产品已经在我的帐户。
警告:为第16行的C:\wamp\www\bigcommerce\index.php中的foreach()提供的无效参数
任何形式的帮助都会被接受.请帮忙..。它是迫切需要的..。
发布于 2013-07-02 01:15:23
所以,这是因为路径中有完整的URL。把它改成下面这样的东西-
Bigcommerce::configure(array(
'store_url' => 'https://store-atka90u.mybigcommerce.com/',
'username' => 'admin',
'api_key' => '4581223546f2bf73840d84b4802cab039f249404'
));发布于 2013-09-11 20:53:40
尝尝这个
<?php
// provision for laziness
if(
(array_key_exists('store_url', (array)$settings)) &&
(array_key_exists('username', $settings)) &&
(array_key_exists('api_key', $settings))
) {
// Config Basic
BC::configure(
array(
'store_url' => $settings['store_url'],
'username' => $settings['username'],
'api_key' => $settings['api_key']
)
);
// Set Cipher if needed
if(array_key_exists('cipher',$settings)) {
BC::setCipher('RC4-SHA');
} else {
BC::verifyPeer(false);
}
// Set Proxy if needed
if(array_key_exists('proxy',$settings)) {
BC::useProxy($settings['proxy']['url'], $settings['proxy']['port']);
}
}
// Run your code here...显然,您需要配置$settings数组,使其至少包括store_url、api_key和用户名.
https://stackoverflow.com/questions/17404419
复制相似问题