![](/img/trans.png)
[英]WooCommerce Rest API - woocommerce_api_invalid_remote_product_image
[英]woocommerce rest api product image in localhost
我有一個woocommerce網站( https://example.com ),我需要使用我在localhost(xampp)上的wordpress來控制此網站的產品...我可以使用woocommerce的其余api創建產品,但是我無法為此設置圖片product。每次我使用rest api發送創建產品請求時,都會收到此錯誤:
stdClass對象([代碼] => woocommerce_product_image_upload_error [消息] =>獲取遠程圖像http://localhost/wordpress/wp-content/uploads/2018/08/6550-min.jpg時出錯。錯誤:未提供有效的URL .. [數據] => stdClass對象([狀態] => 400))
我怎樣才能解決這個問題?
Wordpress拒絕對其他主機的調用。 Localhost是與example.com不同的主機,即使它們位於同一台計算機上也是如此。
您可以使用http_request_host_is_external
過濾器允許localhost:
add_filter( 'http_request_host_is_external', 'allow_localhost', 10, 3 );
function allow_localhost( $allow, $host, $url ) {
if ( $host == 'localhost' ) {
$allow = true;
}
return $allow;
}
您應該在主題的functions.php
添加以上代碼。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.