【问题标题】:BigCommerce PHP API Connection failureBigCommerce PHP API 连接失败
【发布时间】:2015-09-15 00:56:28
【问题描述】:

我将尝试使用 PHP 为我的 bigcommerce 商店编写一个小集成。但是,我似乎无法通过简单地建立连接来通过第一阶段。

我已经阅读了人们遇到相同问题的各种主题,但没有提供的答案似乎对我有用。

我在我的 Windows 7 机器上运行 AMPPS,并编写了一个简单的 PHP 脚本来从 BigCommerce 商店获取时间。这是我的 php 文件。

<?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');
}

?>

我没有收到任何错误,但我也收到空白回复。我查看了我的 bigcommerce 商店上的请求日志,发现它返回了 401 错误。

我的想法很新鲜,所以任何帮助都会很棒。

干杯

【问题讨论】:

    标签: php bigcommerce


    【解决方案1】:

    在配置客户端后设置密码列表。

    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;
    }
    

    这应该让你开始......干杯!

    【讨论】:

      【解决方案2】:

      在努力发现我的代码总是出错的地方之后,我发现最好自己对错误进行适当的检查,比如

      $ping = Bigcommerce_Api::getTime();
      
      
      if (!$ping ) {
      $error = Bigcommerce::getLastError();
      print_r($error);
      }   
      

      这应该告诉您错误的真正位置,尽管还有其他方法可以找出它为什么不起作用。 如果我们得到控制台的错误响应,我们都知道它是最好的。这使您更快地找到解决方案 您可以在此处找到有关错误代码的更多信息 http://developer.bigcommerce.com/docs/api/v2/response_codes

      希望对你有帮助

      【讨论】:

        【解决方案3】:

        我已经运行了这些命令

        作曲家需要 bigcommerce/api 作曲家更新 作曲家需要 phpunit/phpunit

        但这仍然出现致命错误:第 8 行的 D:\xampp\htdocs\bigcommerce-api-php\Tests\ApiTest.php 中找不到类 'PHPUnit_Framework_TestCase'

        另外,这个配置 代码store.mybigcommerce.com', 'username' =- 'admin', 'api_key' =- 'd81aada4xc34xx3e18f0xxxx7f36ca'))

        必须在 vendor/autoload.php 上? 在这段代码之间:`require_once DIR 。 '/作曲家' 。 '/autoload_real.php';

        返回 ComposerAutoloaderInit4248087c0febd66e99bdb31c874f1d0f::getLoader();`

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2016-03-19
          • 2012-08-30
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-06-10
          • 2016-09-15
          相关资源
          最近更新 更多