Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/api/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress ShopifAPI创建产品退货404_Wordpress_Api_Shopify - Fatal编程技术网

Wordpress ShopifAPI创建产品退货404

Wordpress ShopifAPI创建产品退货404,wordpress,api,shopify,Wordpress,Api,Shopify,我正在创建一个从WordPress调用Shopify API的私人应用程序。当我调用创建一个新的Shopify产品时,API创建了该产品,但返回一个404NotFound错误。我相信我的代码是正确的,因为它成功地在运行apache和PHP5.2.x的WindowsXP机器上的本地主机上创建了产品和相应的成功响应。当我从运行Linux、apache和PHP5.3.x的开发服务器上运行它时,我会遇到问题。什么会导致Shopify API创建产品但返回404?我将在下面包括一个呼叫和响应的日志。这篇文

我正在创建一个从WordPress调用Shopify API的私人应用程序。当我调用创建一个新的Shopify产品时,API创建了该产品,但返回一个404NotFound错误。我相信我的代码是正确的,因为它成功地在运行apache和PHP5.2.x的WindowsXP机器上的本地主机上创建了产品和相应的成功响应。当我从运行Linux、apache和PHP5.3.x的开发服务器上运行它时,我会遇到问题。什么会导致Shopify API创建产品但返回404?我将在下面包括一个呼叫和响应的日志。这篇文章确实成功地创建了一个产品,但由于它返回了一个错误,我无法检索新创建的产品id

[cookies] => Array
    (
    )

[body] => Array
    (
        [product] => Array
            (
                [title] => Bracelet 7
                [body_html] => Bracelet 7 descr
                [vendor] => xxx
                [product_type] => bracelet
                [published] => 1
                [images] => Array
                    (
                        [src] => http://xxx.colab.coop/xxx/stb-1.png
                    )

                [variants] => Array
                    (
                        [option1] => small
                        [price] => 123
                        [inventory_management] => shopify
                        [sku] => 234
                        [grams] => 226.79618519019
                        [inventory_quantity] => 123
                    )

            )

    )

[compress] => 
[decompress] => 1
[sslverify] => 1
[stream] => 
[filename] => 
谢谢, 史蒂夫

[cookies] => Array
    (
    )

[body] => Array
    (
        [product] => Array
            (
                [title] => Bracelet 7
                [body_html] => Bracelet 7 descr
                [vendor] => xxx
                [product_type] => bracelet
                [published] => 1
                [images] => Array
                    (
                        [src] => http://xxx.colab.coop/xxx/stb-1.png
                    )

                [variants] => Array
                    (
                        [option1] => small
                        [price] => 123
                        [inventory_management] => shopify
                        [sku] => 234
                        [grams] => 226.79618519019
                        [inventory_quantity] => 123
                    )

            )

    )

[compress] => 
[decompress] => 1
[sslverify] => 1
[stream] => 
[filename] => 
2012-06-05@17:47:36:请求发送至 https://xxx:xxx@colab-5.myshopify.com/admin/products.json 参数:数组 ( [方法]=>POST [超时]=>5 [重定向]=>5 [httpversion]=>1.0 [用户代理]=>WordPress/3.3.2;http://xxx.colab.coop [阻塞]=>1 [标题]=>数组 ( )

[cookies] => Array
    (
    )

[body] => Array
    (
        [product] => Array
            (
                [title] => Bracelet 7
                [body_html] => Bracelet 7 descr
                [vendor] => xxx
                [product_type] => bracelet
                [published] => 1
                [images] => Array
                    (
                        [src] => http://xxx.colab.coop/xxx/stb-1.png
                    )

                [variants] => Array
                    (
                        [option1] => small
                        [price] => 123
                        [inventory_management] => shopify
                        [sku] => 234
                        [grams] => 226.79618519019
                        [inventory_quantity] => 123
                    )

            )

    )

[compress] => 
[decompress] => 1
[sslverify] => 1
[stream] => 
[filename] => 
)

[cookies] => Array
    (
    )

[body] => Array
    (
        [product] => Array
            (
                [title] => Bracelet 7
                [body_html] => Bracelet 7 descr
                [vendor] => xxx
                [product_type] => bracelet
                [published] => 1
                [images] => Array
                    (
                        [src] => http://xxx.colab.coop/xxx/stb-1.png
                    )

                [variants] => Array
                    (
                        [option1] => small
                        [price] => 123
                        [inventory_management] => shopify
                        [sku] => 234
                        [grams] => 226.79618519019
                        [inventory_quantity] => 123
                    )

            )

    )

[compress] => 
[decompress] => 1
[sslverify] => 1
[stream] => 
[filename] => 

2012-06-05@17:47:37:收到来自 https://xxx:xxx@colab-5.myshopify.com/admin/products.json 传输:WP_HTTP_curl 响应:数组 ( [标题]=>数组 ( [服务器]=>nginx [日期]=>2012年6月5日星期二17:47:37格林威治标准时间 [内容类型]=>text/html;字符集=utf-8 [连接]=>关闭 [变化]=>接受编码 [状态]=>404未找到 [缓存控制]=>无缓存 [x-request-id]=>62c48e7991c1f29cf5917727b160cee9 [x-ua-compatible]=>IE=Edge,chrome=1 [x-runtime]=>0.025681 )

[cookies] => Array
    (
    )

[body] => Array
    (
        [product] => Array
            (
                [title] => Bracelet 7
                [body_html] => Bracelet 7 descr
                [vendor] => xxx
                [product_type] => bracelet
                [published] => 1
                [images] => Array
                    (
                        [src] => http://xxx.colab.coop/xxx/stb-1.png
                    )

                [variants] => Array
                    (
                        [option1] => small
                        [price] => 123
                        [inventory_management] => shopify
                        [sku] => 234
                        [grams] => 226.79618519019
                        [inventory_quantity] => 123
                    )

            )

    )

[compress] => 
[decompress] => 1
[sslverify] => 1
[stream] => 
[filename] => 

该请求的日志显示您正在调用
POST”/admin/products/PRODUCT\u ID“
。检查您的代码,确保它按照您的想法运行。请注意,所有API调用都应该有一个类型后缀,因此有效的URL应该是
/admin/products/products\u ID.json
/admin/products/products\u ID.xml

如果您将调用的URL放到浏览器中会发生什么?它会返回产品列表还是404?应该ld看起来也没有传递内容类型头。[headers]=>Array([content-type]=>“application/json”)也应该包括在内。浏览器中的url返回产品列表。我的调用都以.json结束。我得到所有工作。我将内容类型添加到标题中。我使用requestb.in.Still 404验证了这一点。如果我在家用计算机上运行相同的代码(Windows XP、apache、PHP 5.2.x)该请求返回一个创建的201。如果我在web场服务器上运行代码(我假设运行Linux、apache、PHP 5.3.x),我会得到404。即使我得到404,该产品仍然是在Shopify中创建的。我正在寻找与home和farm-like编码或其他头设置不同的内容。您是否可以尝试添加[Accept]=>“应用程序/json”标题也是。我不太确定是什么导致了问题。有时只是缺少标题导致了类似的问题。我现在看到我的GET请求也被破坏了。我取消了上一次更改,但它们仍然被破坏,所以我必须在其他地方破坏它。我需要在声明上一次建议无效之前修复它。修复了GET请求。向标题添加“Accept”不会改变尝试添加产品时的行为。但是它会使添加变体变得更糟。我已经能够添加变体。添加变体会返回200,但也会返回Shopify登录页面的内容。我忽略了这一点。当我向标题添加“Accept”参数时,我会得到一个401尝试添加变体时未经授权。在Shopify中成功添加变体,问题在于返回消息。
[cookies] => Array
    (
    )

[body] => Array
    (
        [product] => Array
            (
                [title] => Bracelet 7
                [body_html] => Bracelet 7 descr
                [vendor] => xxx
                [product_type] => bracelet
                [published] => 1
                [images] => Array
                    (
                        [src] => http://xxx.colab.coop/xxx/stb-1.png
                    )

                [variants] => Array
                    (
                        [option1] => small
                        [price] => 123
                        [inventory_management] => shopify
                        [sku] => 234
                        [grams] => 226.79618519019
                        [inventory_quantity] => 123
                    )

            )

    )

[compress] => 
[decompress] => 1
[sslverify] => 1
[stream] => 
[filename] =>