【问题标题】:Bigcommerce API authentication and debuggingBigcommerce API 身份验证和调试
【发布时间】:2014-12-16 17:38:18
【问题描述】:

这是我的代码:

<html>
    <head>
        <title>Bigcommerce API</title>
    </head>
    <body>
        <?php
        include('bigcommerce.php');

        use Bigcommerce\Api\Client as Bigcommerce;

        Bigcommerce::configure(array(
        'store_url' => 'https://xxx.mybigcommerce.com/api/v2/',
        'username'  => 'admin',
        'api_key'   => 'xxx'
        ));

        $ping = Bigcommerce::getTime();
        if ($ping) echo $ping->format('H:i:s');
        echo('hello');
        ?>
    </body>
</html>

我运行它,但没有任何反应。我在浏览器中查看,它没有显示任何错误。我什至如何开始调试?

编辑

我取出 /api/v2,现在看到这个错误:

致命错误:未捕获的异常 'Exception' 带有消息 'DateTime::__construct(): 依赖系统的时区设置是不安全的。您需要使用 date.timezone 设置或 date_default_timezone_set() 函数。如果您使用了这些方法中的任何一种,但仍然收到此警告,您很可能拼错了时区标识符。我们现在选择时区“UTC”,但请设置 date.timezone 以选择您的时区。在 /Library/WebServer/Documents/bigcommerce.php:404 堆栈跟踪:#0 /Library/WebServer/Documents/bigcommerce.php(404): DateTime->__construct('@1418752201') #1 /Library/WebServer/Documents /index.php(19): Bigcommerce\Api\Client::getTime() #2 {main} 在 /Library/WebServer/Documents/bigcommerce.php 第 404 行抛出

谢谢。

编辑

我在 index.php 中添加了以下内容,它可以工作了!

if( ! ini_get('date.timezone') )
{
    date_default_timezone_set('GMT');
}

【问题讨论】:

  • 在文件顶部添加错误报告:&lt;?php ini_set("display_errors", 1); error_reporting(E_ALL); ?&gt; 你甚至都没有看到你好?
  • 我看到你好,抱歉我不清楚。我还添加了错误报告,没有任何显示。如果我将 URL 更改为虚假的,我会收到错误消息。但按原样,没有错误。
  • 你有正确的值来配置它吗?并且您的网址不得包含“/api/v2”部分,因为它会自动放入课程中。参考github.com/bigcommerce/bigcommerce-api-php/blob/master/…
  • 我取出 /api/v2 并用我现在看到的内容对原始帖子进行了编辑。

标签: php html api debugging bigcommerce


【解决方案1】:

我在 index.php 中添加了以下内容,它可以工作了!

if( ! ini_get('date.timezone') )
{
    date_default_timezone_set('GMT');
}

– 红灯笼

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多