首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >BigCommerce API授权?

BigCommerce API授权?
EN

Stack Overflow用户
提问于 2016-04-13 12:37:26
回答 2查看 737关注 0票数 3

我正在使用PHP的BigCommerce库。我似乎有麻烦,并不断收到错误信息。我不确定这是授权问题还是我遗漏了什么。

我正在使用XAMPP和install以及我需要的BigCommerce程序包。我遵循了这个指南:https://github.com/bigcommerce/bigcommerce-api-php

下面是我的代码(凭据X输出):

代码语言:javascript
复制
<?php

require "vendor/autoload.php";

use Bigcommerce\Api\Client as Bigcommerce;


    Bigcommerce::configure(array(

        'store_url' => 'http://store-XXXXXXXX.mybigcommerce.com',
        'username' => 'admin',
        'api_key' => 'xxxxxxxxxxxxxxxxxxxxxxxxx'
    ));


$ping = Bigcommerce::getTime();


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


?>

返回:Array ( [0] => stdClass Object ( [status] => 400 [message] => The connection is not secure. API requests must be made via HTTPS. ) )

我想知道这是否与我在配置中使用的"store_url“有关。因此,我将其更改为前端URL (我的商店的真实名称),在这样做后,我得到了以下消息:

代码语言:javascript
复制
Fatal error: Uncaught exception 'Bigcommerce\Api\NetworkError' with message 'SSL certificate problem: self signed certificate in certificate chain' in C:\xampp\htdocs\test\PSC_BigC\bigcommerce-api-php-master\src\vendor\bigcommerce\api\src\Bigcommerce\Api\Connection.php:274 Stack trace: #0 C:\xampp\htdocs\test\PSC_BigC\bigcommerce-api-php-master\src\vendor\bigcommerce\api\src\Bigcommerce\Api\Connection.php(368): Bigcommerce\Api\Connection->handleResponse() #1 C:\xampp\htdocs\test\PSC_BigC\bigcommerce-api-php-master\src\vendor\bigcommerce\api\src\Bigcommerce\Api\Client.php(423): Bigcommerce\Api\Connection->get('https://psc-dev...') #2 C:\xampp\htdocs\test\PSC_BigC\bigcommerce-api-php-master\src\test.php(19): Bigcommerce\Api\Client::getTime() #3 {main} thrown in C:\xampp\htdocs\test\PSC_BigC\bigcommerce-api-php-master\src\vendor\bigcommerce\api\src\Bigcommerce\Api\Connection.php on line 274
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-04-13 12:49:46

这是因为你使用的是一个自签名的证书。

您需要配置Bigcommerce来忽略警告。

代码语言:javascript
复制
Bigcommerce::verifyPeer(false);

这有效地关闭了它似乎正在使用的cURL客户机中的检查功能。

票数 3
EN

Stack Overflow用户

发布于 2016-04-13 13:19:07

错误声明:"API请求必须通过HTTPS进行。“

将您的存储URL更改为"https://store-XXXXXXXX.mybigcommerce.com“,因为它是安全的。

文档中的示例(存储URL需要是HTTPS)。

https://github.com/bigcommerce/bigcommerce-api-php

代码语言:javascript
复制
Bigcommerce::configure(array(
    'store_url' => 'https://store.mybigcommerce.com',
    'username'  => 'admin',
    'api_key'   => 'd81aada4xc34xx3e18f0xxxx7f36ca'
));
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36598635

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档