私はWooCommerce-REST-API-Client-Library-v2を使用しており、簡単なget orders呼び出しを試みています。 httpでテストサーバーへの接続を確立することに問題はありませんが、httpsを使用してプロダクションサーバーに接続しようとすると、無効なJSONが応答でエラーを返しました。セキュリティで保護されたチェックアウトは、Woocommerce設定で有効になっています。私は資格情報をbase64_encodingの有無にかかわらず試しました。誰かが私に間違っていることを教えてもらえますか、またはWooCommerce-REST-API-Client-Library-v2を使用してHTTPSで認証するための適切なフォーマットの例を提供できますか?ここに私のコードです。ありがとう!HTTPS(Basic Auth)を使用してWoocommerce APIで認証する方法
$consumer_key = base64_encode('ck_removed'); // Add your own Consumer Key here
$consumer_secret = base64_encode('cs_removed'); // Add your own Consumer Secret here
$store_url = 'https://removed.co.uk'; // Add the home URL to the store you want to connect to here
$is_ssl= TRUE;
try {
$client = new WC_API_Client($consumer_key, $consumer_secret, $store_url);
// Get WC Orders Request
$orders=$client->orders->get();
$orders=$orders['orders'];
} 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());
}
}