我已经在实时服务器上上传了woocommerce API,但响应为空白时却无法正常工作,但是可以在localhost上成功运行。
以下是我通过id获取订单的代码
<?php
include('../wp-load.php');
require_once( 'woo-lib/autoload.php' );
use Automattic\WooCommerce\Client;
$woocommerce = new Client(
'http://tesmy.com',
'ck_xxxxx',
'cs_xxxx',
[
'wp_api' => true,
'version' => 'wc/v1',
]
);
if(isset($_REQUEST['order_id']) && empty($_REQUEST['order_id'])){
$result = array('status'=>false,'message'=>'Order id is required.');
header('Content-Type: application/json');
echo json_encode($result);
die();
}
$orderId=$_REQUEST['order_id'];
$orderDetails=$woocommerce->get('orders/'.$orderId);
if(isset($orderDetails) && !empty($orderDetails)){
$result = array('status'=>true,'message'=>'Order details','data'=>$orderDetails);
}else{
$result = array('status'=>false,'message'=>'Something went wrong');
}
header('Content-Type: application/json');
echo json_encode($result);
die();
同一件事在我的本地服务器上有效,但在实时服务器上无效。
请帮助我,id应该怎么做?