Woocommerce 产品 api 不接受某些网址中的图片

Woocommerce product api not accept images in some urls

我在 woocommerce 网站上从外部创建产品。我的代码如下所示:

if($_POST["Type"] == "CREATE"){
         $data = array(
            'product' => array(
                'title' => $_POST["Title"],
                'type' => 'simple',
                'regular_price' => $_POST["Regular_price"],
                'description' => $_POST["Description"],
                'short_description' => $_POST["Short_description"],
                'categories' => array(
                    $_POST['CategoryName']
                ),
                'images' => array(
                    array(
                        'src' => $_POST["Image_url"],
                        'position' => 0
                    ),
                    array(
                        'src' => $_POST["Image_url"],
                        'position' => 1
                    )
                )
            )
        );
    $res = $client->products->create($data);
}

当使用 $_POST["Image_url"] 时,例如 http://app.test.net:8080/test/img/company-logo.png 会出现以下错误:

PHP Fatal error:  Uncaught exception 'WC_API_Client_HTTP_Exception' with message 'Error: Error getting remote image

但是如果我们给一个正常的url(url不包含特定的端口)比如http://test.com/wp-content/uploads/2016/02/test.png它工作正常。

如何解决?

---- (编辑 2) ----

抱歉,您的问题一点都不清楚。你必须更新它,因为它非常不完整和模糊。标题也一样。

媒体图像位于端口 8080 上的第二台服务器中,对吧……

请告诉我问题出在:

'images' => array(
    array(
        'src' => $_POST["Image_url"],
        'position' => 0
    ),
    array(
        'src' => $_POST["Image_url"],
        'position' => 0
    )
)

'src' => $_POST["Image_url"]

看看这个有趣的相关话题:Synchronize external database with woocommerce database

在我的例子中,上面提到的代码中有这样一个 URL (http://app.test.net:8080/api/v1/product.php). Calling this API from .net application by (http://appname.test.net)。两者都具有相同的域部分 (test.net)。

因此很难找到 URL 来吸引 commerce.I 通过我的服务器配置(我使用虚拟主机)更改 URL .net 应用程序。然后就可以了适当地。