承接 wic/woocommerce-api 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

wic/woocommerce-api

最新稳定版本:v0.3.1

Composer 安装命令:

composer require wic/woocommerce-api

包简介

A client library for the WooCommerce REST API

README 文档

README

About

A PHP wrapper for the WooCommerce REST API. Easily interact with the WooCommerce REST API using this library.

Feedback and bug reports are appreciated, and fixed ASAP.

Installation

Via Composer

$ composer require wic/woocommerce-api

Requirements

PHP 5.4.x cURL WooCommerce 2.2 at least on the store

Getting started

Generate API credentials (Consumer Key & Consumer Secret) under WP Admin > Your Profile.

Setup the library

use WIC/Client;

$options = array(
    'ssl_verify'      => false,
);

try {

	$client = new Client( 'http://your-store-url.com', $consumer_key, $consumer_secret, $options );

} catch ( ClientException $e ) {

	echo $e->getMessage() . PHP_EOL;
	echo $e->getCode() . PHP_EOL;

	if ( $e instanceof ClientHTTPException ) {

		print_r( $e->get_request() );
		print_r( $e->get_response() );
	}
}

Options

  • debug (default false) - set to true to add request/response information to the returned data. This is particularly useful for troubleshooting errors.

  • return_as_array (default false) - all methods return data as a stdClass by default, but you can set this option to true to return data as an associative array instead.

  • validate_url (default false) - set this to true to verify that the URL provided has a valid, parseable WC API index, and optionally force SSL when supported.

  • timeout (default 30) - set this to control the HTTP timeout for requests.

  • ssl_verify (default true) - set this to false if you don't want to perform SSL peer verification for every request.

Error handling

Exceptions are thrown when errors are encountered, most will be instances of ClientHTTPException which has two additional methods, get_request() and get_response() -- these return the request and response objects to help with debugging.

Methods

Index

  • $client->index->get() - get the API index

Orders

  • $client->orders->get() - get a list of orders
  • $client->orders->get( null, array( 'status' => 'completed' ) ) - get a list of completed orders
  • $client->orders->get( $order_id ) - get a single order

Credit

Copyright (c) 2013-2015 - Web In Color, Gerhard Potgieter, Max Rice and other contributors

License

Released under the GPL3 license

统计信息

  • 总下载量: 1.56k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 170
  • 开发语言: PHP

其他信息

  • 授权协议: GPL
  • 更新时间: 2015-06-01