PHP的Bigcommerce API - 无返回的数据 [英] Bigcommerce PHP API - No data returned

查看:285
本文介绍了PHP的Bigcommerce API - 无返回的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是单个文件PHP库。我有实体店连接,但我没有得到回数据。这里是我的脚本:

I'm using the single file PHP library. I've got the store connecting, but I am getting no data back. Here is my script:

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

    $settings = array('store_url' => 'https://STORE_URL_REDACTED.mybigcommerce.com','username' => 'USERNAME_REDACTED', 'api_key' => 'API_KEY_REDACTED');

    if( 
        (array_key_exists('store_url', (array)$settings)) &&
        (array_key_exists('username', $settings)) && 
        (array_key_exists('api_key', $settings)) 
    ) {
        // Config Basic
        Bigcommerce::configure(
            array(
                'store_url' => $settings['store_url'],
                'username'  => $settings['username'],
                'api_key'   => $settings['api_key']
            )
        );
        Bigcommerce::setCipher('RC4-SHA');
        Bigcommerce::verifyPeer(false);
    }    

$products = Bigcommerce::getProducts();

$orders = Bigcommerce::getOrders();

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

我有在bigcommerce.php卷曲命令的输出写作,我可以看到我实际连接到商店:

I've got output writing on the curl commands in bigcommerce.php, and I can see that I am actually connecting to the store:


  • 关于以()连接到STORE_ID_REDACTED.mybigcommerce.com端口443(#0)*试图绝密... * *连接连接到STORE_ID_REDACTED.mybigcommerce.com(绝密)端口443(#0)*设置成功验证证书地点:*凭证档案错误:cacert.pem CApath:使用RC4-SHA的/ etc / SSL /证书* SSL连接*服务器证书:*主题:C = US;邮政code = 49519; ST =密执安; L =怀俄明;街道= 3343佩里大道SW; O =绝密; OU = InstantSSL; CN =绝密*起始日期:2011-08-22 00:00:00 GMT *到期日期:2016年8月21日23时59分59秒GMT *发行人:C = GB; ST =大曼彻斯特; L =索尔福德; O = COMODO CA有限公司; CN = COMODO高保证安全服务器CA * SSL证书验证确定。使用基本与用户*服务器授权'USERNAME_REDACTED'> GET / API / V2 /产品HTTP / 1.1授权:基本绝密主持人:store-STORE_ID_REDACTED.mybigcommerce.com接受:应用/ JSON&LT; HTTP / 1.1 200 OK下;日期:星期二,2013年12月3日16时32分57秒GMT&LT;服务器:Apache&LT;最后一次修改:星期二,2013年12月3日六时25分44秒+0000&LT;的X BC-ApiLimit-剩余:17167&LT;的X BC-STORE-版本:7.6.0&LT;的X技术,通过:PleskLin&LT;传输编码:分块&LT;内容类型:应用程序/ JSON&LT; *连接#0主办STORE_ID_REDACTED.mybigcommerce.com原封不动*重新使用现有的连接! (#0)与主机STORE_ID_REDACTED.mybigcommerce.com *连接到STORE_ID_REDACTED.mybigcommerce.com(节录)端口443使用基本与用户(#0)*服务器授权'USERNAME_REDACTED'> GET / API / V2 /订单HTTP / 1.1授权:基本绝密主持人:绝密接受:应用/ JSON&LT; HTTP / 1.1 200 OK下;日期:星期二,2013年12月3日16时32分58秒GMT&LT;服务器:Apache&LT;最后一次修改:星期四,2010 11月18日十七时四十分55秒+0000&LT;的X BC-ApiLimit-剩余:17162&LT;的X BC-STORE-版本:7.6.0&LT;的X技术,通过:PleskLin&LT;传输编码:分块&LT;内容类型:应用程序/ JSON&LT; *连接#0主办STORE_ID_REDACTED.mybigcommerce.com原封不动*关闭连接#0

我收到以下错误:

Warning: Invalid argument supplied for foreach() in /home/zetaphor/public_html/bigcommerce-api-php-master/coupons.php

我返回数组包含任何数据。

My returned arrays contain no data.

我使用PHP 5.3.3运行LAMP堆栈,使卷曲

I am running a LAMP stack using PHP 5.3.3, cURL enabled

推荐答案

我正面临着PHP类的问题,所以我已经做到了这一点使用curl,
你可以让你的店铺的产品,订单和优惠券。

I was facing that problem in php class, so i have done this using CURL, You can get your stores products, orders and coupon.

这里是code。

    $username = 'your username'; 
    $password = 'your key';
    $url = ' your store url';
    $product_url = $url.'/api/v2/products.json';

    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, $product_url);
    curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_USERPWD, $username . ":" . $password);
    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
    curl_setopt($curl, CURLOPT_ENCODING, "");
    $curlData = curl_exec($curl);
    curl_close($curl);
    //returning retrieved feed

    $product_rec  = json_decode($curlData);
    echo '<pre>';
    print_r($product_rec);

现在订单使用

    $order_url =  $url.'/api/v2/orders.json'; 

这篇关于PHP的Bigcommerce API - 无返回的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆