Reputation: 1
I will be attempting to write a little integration for my bigcommerce store using PHP. However, I can't seem to get past the first stage by simply making a connection.
I have read through various topics of people having the same issue but no answers provided seem to work for me.
I am running AMPPS on my Windows 7 machine and wrote a simple PHP script to get the time from the BigCommerce store. Here is my php file.
<?php
require_once 'Bigcommerce/Api.php';
Bigcommerce_Api::setCipher('RC4-SHA');
Bigcommerce_Api::verifyPeer(false);
Bigcommerce_Api::configure(array(
'store_url' => 'https://store-hxxhy.mybigcommerce.com',
'username' => 'admin',
'api_key' => '4bf35c13c9b383ab9df15c48d250841bfb03e416'
));
$ping = Bigcommerce_Api::getTime();
if ($ping)
{
echo $ping->format('H:i:s');
}
?>
I get no errors but I also get a blank response. I looked at the requests log on my bigcommerce store and I notice it returns a 401 error.
I'm fresh out of ideas so any assistance would be great.
Cheers
Upvotes: 0
Views: 1596
Reputation: 11
I already run these comands
composer require bigcommerce/api composer update composer require phpunit/phpunit
but this is still appearing Fatal error: Class 'PHPUnit_Framework_TestCase' not found in D:\xampp\htdocs\bigcommerce-api-php\Tests\ApiTest.php on line 8
Also, this configuration
codestore.mybigcommerce.com', 'username' =- 'admin', 'api_key' =- 'd81aada4xc34xx3e18f0xxxx7f36ca'))
Must be on vendor/autoload.php ? between this code:`require_once DIR . '/composer' . '/autoload_real.php';
return ComposerAutoloaderInit4248087c0febd66e99bdb31c874f1d0f::getLoader();`
Upvotes: 1
Reputation: 252
After struggling a lot with discovering where my code is always wrong, i discovered that its best if you do a proper check on the errors yourself , like
$ping = Bigcommerce_Api::getTime();
if (!$ping ) {
$error = Bigcommerce::getLastError();
print_r($error);
}
this should tell you where the error really is, though there are other ways of finding out why it didnt work. and we all know its best if we get an error response to the console. this makes your work faster towards finding a solution you can find more about error codes here http://developer.bigcommerce.com/docs/api/v2/response_codes
i hope this helps
Upvotes: 1
Reputation: 713
set the cipher list after you configure your client.
require_once 'Bigcommerce/Api.php';
Bigcommerce_Api::configure(array(
'store_url' => 'https://store-xxxx.mybigcommerce.com',
'username' => 'test',
'api_key' => 'xxxxx'
));
Bigcommerce_Api::setCipher('RC4-SHA');
Bigcommerce_Api::verifyPeer(false);
$products = Bigcommerce_Api::getProducts();
foreach($products as $product) {
echo $product->name;
echo $product->price;
}
This should get you going...Cheers!
Upvotes: 2