【发布时间】:2014-11-13 06:11:10
【问题描述】:
编辑: 万一有人在读这篇文章,我在记录 v2 api 之前发表了这篇文章,但是文档现在可用,所以如果您遇到问题,请参阅:http://woothemes.github.io/woocommerce-rest-api-docs/#introduction
我正在尝试更新此处找到的 PHP REST API 客户端库:https://github.com/kloon/WooCommerce-REST-API-Client-Library。
我将 API_ENDPOINT 更改为 wc-api/v2/ 并添加了这个函数:
public function create_order( $data ) {
return $this->_make_api_call( 'orders/', $data, 'POST' );
}
我明白了:
Warning: rawurldecode() expects parameter 1 to be string, array given in /home/class-wc-api-client- v2.php on line 441
Warning: rawurldecode() expects parameter 1 to be string, array given in /home/class-wc-api-client-v2.php on line 441
object(stdClass)#1801 (1) {
["errors"]=>
array(1) {
[0]=>
object(stdClass)#1798 (2) {
["code"]=>
string(3) "401"
["message"]=>
string(19) "cURL HTTP error 401"
}
}
}
我正在使用以下代码调用 create_order
$data = array(
"status" => "processing",
"payment_details" => array("method_id" => "paypal", "method_title" => "PayPal", "paid" => 1),
"line_items" => array("id" => 123, "subtotal" => 45.00, "total" => 45.00, "total_tax" => 0.00, "price" => 45.00, "quantity" => 1, "name" => "itemName", "product_id" => 123)
);
var_dump($wc_api->create_order($data));
有什么帮助吗?
谢谢!
【问题讨论】:
标签: php wordpress woocommerce woothemes