WordPress localhost上的WooCommerce woocommerce_rest_authentication_error

我正在尝试解决此问题,但无法找到它。</ p>

我正在使用Woocommerce API开发一个WordPress插件,即尝试从外部JSON源插入产品读取。 因此,当我尝试致电</ p>

  $ woocommerce-&gt; get('products',$ data); 
</ code> </ pre>

< 我得到了一个致命的错误:</ p>

 致命错误:Uncaught Automattic \ WooCommerce \ HttpClient \ HttpClientException:错误:Firma non valida  -  la firma fornita non corrisponde。  [woocommerce_rest_authentication_error] /Users/hal/Documents/www/wordpress/wp-content/plugins/.../vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php:324
</ pre>

(此处未报告StackTrace,无法查找其他信息)。</ p>

报告的错误是 401 </ strong>,这个最奇怪 事情是localhost上的相同代码不起作用,如果我上传&amp; 在生产VPS上尝试相同的代码...它的工作原理。 搜索了很多关于此问题的主题,直到现在还没有明确的答复,如果是这样的话,我很抱歉。</ p>

$ woocommerce以前被实例化为:</ p>

< pre> $ woocommerce = new Client(
'http:// localhost / wordpress',
'ck _...',//您的消费者密钥
'cs _...',//您的消费者 secret
[
'wp_api'=&gt; true,//启用WP REST API集成
'版本'=&gt;'wc / v2'// WooCommerce WP REST API版本
]
); \ n </ code> </ pre>

ck / cs对刚刚从wordpress生成,网站网址显然是 http:// localhost / wordpress (我尝试没有成功,即 http:// localhost / wordpress < strong> / </ strong>,http s </ strong>:// localhost / wordpress等等)</ p>

如果这可能很重要(...我猜是的 ),我正在尝试在MAMP上调试此代码(apache 在806端口上,mysql在3306上运行@ localhost w /基本安装,在MacOS Sierra 10.12.6上。</ p>

希望我很清楚,任何人都解决了这个问题,提前谢谢</ p >
</ div>

展开原文

原文

I'm trying to get solution for this issue but can't find it out.

I'm developing a WordPress plugin using Woocommerce APIs, i.e trying to insert a product reading from external JSON source. So when I try to call

$woocommerce->get( 'products', $data );

I get a fatal error like that:

Fatal error: Uncaught Automattic\WooCommerce\HttpClient\HttpClientException: Error: Firma non valida - la firma fornita non corrisponde. [woocommerce_rest_authentication_error] in /Users/hal/Documents/www/wordpress/wp-content/plugins/.../vendor/automattic/woocommerce/src/WooCommerce/HttpClient/HttpClient.php:324

(StackTrace not reported here, not useful to find other informations).

Error reported is 401, about this most weird thing is that the same code on localhost does not work, if I upload & try same code it on production VPS ... it works. Searched on many topics about this, no clear responses until now so sorry for duplicate, if is this the case.

$woocommerce was previously instanced as:

$woocommerce = new Client(
            'http://localhost/wordpress',
            'ck_...', // Your consumer key
            'cs_...', // Your consumer secret
            [
            'wp_api' => true, // Enable the WP REST API integration
            'version' => 'wc/v2' // WooCommerce WP REST API version
        ]
);

ck/cs pairs was just generated from wordpress, site url is obviously http://localhost/wordpress (and I tried without success i.e http://localhost/wordpress/, https://localhost/wordpress and so on)

If this could matter (...and I guess yes), I'm trying to debug this code on MAMP (apache on 80 port, mysql on 3306) running @ localhost w/ basic installation, on MacOS Sierra 10.12.6.

Hope I was clear and anyone solved this problem, thanks in advance

1个回答



如果您正在使用http请求,则必须使用oauth授权rest api </ p>
</ div>

展开原文

原文

If You are using http request then you have to user oauth for authorization for rest api

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐