2013-11-26 99 views
0

我有下面的代碼:的Bigcommerce SSL問題

<?php 
error_reporting(E_ALL); 
ini_set('display_errors', True); 
require 'bigcommerce.php'; 
    use Bigcommerce\Api\Client as Bigcommerce; 


    Bigcommerce::configure(array(
    'store_url' => 'Our URL is here and valid', 
    'username' => 'Our username is here and valid', 
    'api_key' => 'Our key is here and valid' 
    )); 

    Bigcommerce::setCipher('RC4-SHA');  
    Bigcommerce::verifyPeer(false); 

$products = Bigcommerce::getProducts(); 

foreach($products as $product) { 
    echo $product->name; 
    echo $product->price; 
} 
?> 

當我運行它,我得到以下的輸出:

Fatal error: Uncaught exception 'Bigcommerce\Api\NetworkError' with message 'SSL peer  certificate or SSH remote key was not OK' in /home/zetaphor/public_html/bigcommerce-api-php-master/bigcommerce.php:82 Stack trace: #0 /home/zetaphor/public_html/bigcommerce-api-php-master/bigcommerce.php(142): Bigcommerce\Api\Connection->handleResponse() #1 /home/zetaphor/public_html/bigcommerce-api-php-master/bigcommerce.php(333): Bigcommerce\Api\Connection->get('https://store-9...') #2 /home/zetaphor/public_html/bigcommerce-api-php-master/bigcommerce.php(408): Bigcommerce\Api\Client::getCollection('/products', 'Product') #3 /home/zetaphor/public_html/bigcommerce-api-php-master/coupons.php(17): Bigcommerce\Api\Client::getProducts() #4 {main} thrown in /home/zetaphor/public_html/bigcommerce-api-php-master/bigcommerce.php on line 82 

回答

0

貌似我想通了自己。

到下述兩行添加到Bigcommerce.php的構造函數(API的單文件版本)

curl_setopt($this->curl, CURLOPT_SSL_VERIFYHOST, 0); 
curl_setopt($this->curl, CURLOPT_SSL_VERIFYPEER, 0); 

這並提出一些安全問題,但該文件將在本地的運行一次性報告。