• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

kloon/WooCommerce-REST-API-Client-Library: A PHP wrapper for the WooCommerce RES ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

kloon/WooCommerce-REST-API-Client-Library

开源软件地址(OpenSource Url):

https://github.com/kloon/WooCommerce-REST-API-Client-Library

开源编程语言(OpenSource Language):

PHP 100.0%

开源软件介绍(OpenSource Introduction):

WooCommerce REST API PHP Client Library

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.

Requirements

PHP 5.2.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

require_once( 'lib/woocommerce-api.php' );

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

try {

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

} catch ( WC_API_Client_Exception $e ) {

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

	if ( $e instanceof WC_API_Client_HTTP_Exception ) {

		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 WC_API_Client_HTTP_Exception 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-2014 - Gerhard Potgieter, Max Rice and other contributors

License

Released under the GPL3 license




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
grpc/grpc-docker-library: Contains dockerfiles for gRPC in different languages发布时间:2022-08-15
下一篇:
Mirantis/pipeline-library发布时间:2022-08-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap