I'm using the single file PHP library. I've got the store connecting, but I am getting no data back. Here is my script:
<?php
error_reporting(E_ALL);
ini_set('display_errors', True);
require 'bigcommerce.php';
use Bigcommerce\Api\Client as Bigcommerce;
$settings = array('store_url' => 'https://STORE_URL_REDACTED.mybigcommerce.com','username' => 'USERNAME_REDACTED', 'api_key' => 'API_KEY_REDACTED');
if(
(array_key_exists('store_url', (array)$settings)) &&
(array_key_exists('username', $settings)) &&
(array_key_exists('api_key', $settings))
) {
// Config Basic
Bigcommerce::configure(
array(
'store_url' => $settings['store_url'],
'username' => $settings['username'],
'api_key' => $settings['api_key']
)
);
Bigcommerce::setCipher('RC4-SHA');
Bigcommerce::verifyPeer(false);
}
$products = Bigcommerce::getProducts();
$orders = Bigcommerce::getOrders();
foreach($products as $product) {
echo $product->name;
echo $product->price;
}
?>
I've got output writing on the curl commands in bigcommerce.php, and I can see that I am actually connecting to the store:
- About to connect() to STORE_ID_REDACTED.mybigcommerce.com port 443 (#0) * Trying REDACTED... * connected * Connected to STORE_ID_REDACTED.mybigcommerce.com (REDACTED) port 443 (#0) * successfully set certificate verify locations: * CAfile: cacert.pem CApath: /etc/ssl/certs * SSL connection using RC4-SHA * Server certificate: * subject: C=US; postalCode=49519; ST=Michigan; L=Wyoming; street=3343 Perry Ave SW; O=REDACTED; OU=InstantSSL; CN=REDACTED * start date: 2011-08-22 00:00:00 GMT * expire date: 2016-08-21 23:59:59 GMT * issuer: C=GB; ST=Greater Manchester; L=Salford; O=COMODO CA Limited; CN=COMODO High-Assurance Secure Server CA * SSL certificate verify ok. * Server auth using Basic with user 'USERNAME_REDACTED' > GET /api/v2/products HTTP/1.1 Authorization: Basic REDACTED Host: store-STORE_ID_REDACTED.mybigcommerce.com Accept: application/json < HTTP/1.1 200 OK < Date: Tue, 03 Dec 2013 16:32:57 GMT < Server: Apache < Last-Modified: Tue, 03 Dec 2013 06:25:44 +0000 < X-BC-ApiLimit-Remaining: 17167 < X-BC-Store-Version: 7.6.0 < X-Powered-By: PleskLin < Transfer-Encoding: chunked < Content-Type: application/json < * Connection #0 to host STORE_ID_REDACTED.mybigcommerce.com left intact * Re-using existing connection! (#0) with host STORE_ID_REDACTED.mybigcommerce.com * Connected to STORE_ID_REDACTED.mybigcommerce.com (REDACTED) port 443 (#0) * Server auth using Basic with user 'USERNAME_REDACTED' > GET /api/v2/orders HTTP/1.1 Authorization: Basic REDACTED Host: REDACTED Accept: application/json < HTTP/1.1 200 OK < Date: Tue, 03 Dec 2013 16:32:58 GMT < Server: Apache < Last-Modified: Thu, 18 Nov 2010 17:40:55 +0000 < X-BC-ApiLimit-Remaining: 17162 < X-BC-Store-Version: 7.6.0 < X-Powered-By: PleskLin < Transfer-Encoding: chunked < Content-Type: application/json < * Connection #0 to host STORE_ID_REDACTED.mybigcommerce.com left intact * Closing connection #0
I get the following error:
Warning: Invalid argument supplied for foreach() in /home/zetaphor/public_html/bigcommerce-api-php-master/coupons.php
My returned arrays contain no data.
I am running a LAMP stack using PHP 5.3.3, cURL enabled