PHP API:bigcommerce-api-php, php-shopify

1.  Bigcommerce API Client

PHP client for connecting to the Bigcommerce V2 REST API.

To find out more, visit the official documentation website:





  • PHP 5.3 or greater
  • cUrl extension enabled

To connect to the API with basic auth you need the following:

  • Secure URL pointing to a Bigcommerce store
  • Username of an authorized admin user of the store
  • API key for the user

To generate an API key, go to Control Panel > Users > Edit User and make sure the ‘Enable the XML API?’ is ticked.

To connect to the API with OAuth you will need the following:

  • client_id
  • auth_token
  • store_hash


Use the following Composer command to install the API client from the Bigcommerce vendor on Packagist:

 $ composer require bigcommerce/api
 $ composer update

You can also install composer for your specific project by running the following in the library folder.

 $ curl -sS | php
 $ php composer.phar install
 $ composer install



use Bigcommerce\Api\Client as Bigcommerce;
use Bigcommerce\Api\ClientError;
use Bigcommerce\Api\ServerError;
use Bigcommerce\Api\Error;

include_once rtrim(dirname(__FILE__), '/').'/vendor/autoload.php';

$config = array(
    'store_url' => '',
    'username'	=> 'yoursitename',
    'api_key'	=> 'yoursitekey'


// about products

$product = Bigcommerce::getProduct(11);
echo $product->name;
echo $product->price;

//Paging and Filtering
//All the default collection methods support paging, by passing the page number to the method as an integer:
$products = Bigcommerce::getProducts(3);

//If you require more specific numbering and paging, you can explicitly specify a limit parameter:
$filter = array("page" => 3, "limit" => 30);
$products = Bigcommerce::getProducts($filter);

//To filter a collection, you can also pass parameters to filter by as key-value pairs:
$filter = array("is_featured" => true);
$featured = Bigcommerce::getProducts($filter);

// about customers

// about orders
Bigcommerce::getOrderShippingAddresses($order_id, $filter);
Bigcommerce::getOrderShippingAddress($order_id, $order_shippment_address_id);
Bigcommerce::getShipments($order_id, $filter);
Bigcommerce::getShipment($order_id, $shipment_id);
Bigcommerce::getOrderProductsCount($order_id, $filter);

更多方法函数,可以参看源文件: PHPBigcommerce/vendor/bigcommerce/api/src/Bigcommerce/Api/Client.php

Updating existing resources (PUT)

To update a single resource:

$product = Bigcommerce::getProduct(11);

$product->name = "MacBook Air";
$product->price = 99.95;

You can also update a resource by passing an array or stdClass object of fields you want to change to the global update method:

$fields = array(
	"name"  => "MacBook Air",
	"price" => 999.95

Bigcommerce::updateProduct(11, $fields);

Creating new resources (POST)

Some resources support creation of new items by posting to the collection. This can be done by passing an array or stdClass object representing the new resource to the global create method:

$fields = array(
	"name" => "Apple"


You can also create a resource by making a new instance of the resource class and calling the create method once you have set the fields you want to save:

$brand = new Bigcommerce\Api\Resources\Brand();

$brand->name = "Apple";

Deleting resources and collections (DELETE)

To delete a single resource you can call the delete method on the resource object:

$category = Bigcommerce::getCategory(22);

You can also delete resources by calling the global wrapper method:


Some resources support deletion of the entire collection. You can use the deleteAll methods to do this:


Using The XML API


This will configure the API client to use XML for all subsequent requests. Note that the client does not convert XML to PHP objects. In XML mode, all object parameters to API create and update methods must be passed as strings containing valid XML, and all responses from collection and resource methods (including the ping, and count methods) will return XML strings instead of PHP objects. An example transaction using XML would look like:


$xml = "<?xml version="1.0" encoding="UTF-8"?>
		 	<search_keywords>computers laptops</search_keywords>

$result = Bigcommerce::createBrand($xml);



2. PHP Shopify SDK

PHPShopify is a simple SDK implementation of Shopify API. It helps accessing the API in an object oriented way.





Install with Composer

composer require phpclassic/php-shopify


PHPShopify uses curl extension for handling http calls. So you need to have the curl extension installed and enabled with PHP.

However if you prefer to use any other available package library for handling HTTP calls, you can easily do so by modifying 1 line in each of the get()post()put()delete() methods in PHPShopify\HttpRequestJson class.


You can use PHPShopify in a pretty simple object oriented way.

Configure ShopifySDK

If you are using your own private API, provide the ApiKey and Password.

$config = array(
    'ShopUrl' => '',
    'ApiKey' => '***YOUR-PRIVATE-API-KEY***',
    'Password' => '***YOUR-PRIVATE-API-PASSWORD***',


For Third party apps, use the permanent access token.

$config = array(
    'ShopUrl' => '',
    'AccessToken' => '***ACCESS-TOKEN-FOR-THIRD-PARTY-APP***',




include_once rtrim(dirname(__FILE__), '/').'/vendor/autoload.php';

$config = array(
    'url' => '',
    'key' => 'yousrsitekey',
    'password' => 'yousrsitepassword',

$shopify = new PHPShopify\ShopifySDK($configs);




//  (GET request)
$params = array(
    'status' => 'cancelled',
    'created_at_min' => '2016-06-25T16:15:47-04:00',
    'fields' => 'id,line_items,name,total_price'

$orders = $shopify->Order->get($params);

// Create a new order (POST Request)
$order = array (
    "email" => "",
    "fulfillment_status" => "unfulfilled",
    "line_items" => [
          "variant_id" => 27535413959,
          "quantity" => 5


// Update an order (PUT Request)
$updateInfo = array (
    "fulfillment_status" => "fulfilled",


// Remove a Webhook (DELETE request)
$webHookID = 453487303;

// get the images of a product (GET request)
$productID = 23564666666;
$productImages = $shopify->Product($productID)->Image->get();

// Add a new address for a customer (POST Request)
$address = array(
    "address1" => "129 Oak St",
    "city" => "Ottawa",
    "province" => "ON",
    "phone" => "555-1212",
    "zip" => "123 ABC",
    "last_name" => "Lastnameson",
    "first_name" => "Mother",
    "country" => "CA",

$customerID = 4425749127;


// Create a fulfillment event (POST request)
$fulfillmentEvent = array(
    "status" => "in_transit"


// Update a Blog article (PUT request)
$blogID = 23564666666;
$articleID = 125336666;
$updateArtilceInfo = array(
    "title" => "My new Title",
    "author" => "Your name",
    "tags" => "Tags, Will Be, Updated",
    "body_html" => "<p>Look, I can even update through a web service.<\/p>",

// Delete any specific article from a specific blog (DELETE request)
$blogArticle = $shopify->Blog($blogID)->Article($articleID)->delete();

// Custom Actions - get count of total projects
$productCount = $shopify->Product->count();

// Custom Actions - Make an address default for the customer.

// Custom Actions - Search for customers with keyword "Bob" living in country "United States".
$shopify->Customer->search("Bob country:United States");




本文:PHP API:bigcommerce-api-php, php-shopify


One Comment

Add a Comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.