1

Sandeep Shetty の shopify.php を使用してカスタム製品コレクションを作成しようとしています。製品やカートなどを表示するなど、他の機能的な API 呼び出しを行うことはできましたが、製品 ID の「既知の」リストを使用してカスタム コレクションを作成することはできません。私のコードは次のとおりです。

$charge = array
    (
        "custom_collection"=>array
        (
            "title"=>"ThisTest",
            "collects"=>array(
                "product_id"=>96525818,
                "product_id"=>96393246
            )
        )
    );
    try
    {
        // All requests accept an optional fourth parameter, that is populated with the response headers.
        $my_collect = $shopify('POST', '/admin/custom_collections.json', $charge, $response_headers);

        // API call limit helpers
        echo shopify_calls_made($response_headers); // 2
        echo shopify_calls_left($response_headers); // 298
        echo shopify_call_limit($response_headers); // 300

    }
    catch (ShopifyApiException $e)
    {            
        echo "doh";
        print_r($e);
    }

}

次のエラーが返されます。

ShopifyApiException Object

( [info:protected] => Array ( [method] => POST [path] => /admin/custom_collections.json [params] => Array ( [custom_collection] => Array ( [title] => ToddTest [collects] => 配列 ( [product_id] => 96393246 )

                    )

            )

        [response_headers] => Array
            (
                [http_status_message] => Internal Server Error
                [http_status_code] => 500
                [server] => nginx
                [date] => Mon, 16 Jul 2012 23:23:45 GMT
                [content-type] => application/json; charset=utf-8
                [transfer-encoding] => chunked
                [connection] => keep-alive
                [status] => 500 Internal Server Error
                [x-shopify-shop-api-call-limit] => 18/500
                [http_x_shopify_shop_api_call_limit] => 18/500
                [cache-control] => no-cache
                [x-request-id] => f22337df8773ff4fa2f9f384ca21f133
                [x-ua-compatible] => IE=Edge,chrome=1
                [set-cookie] => _secure_session_id=50f46da87f21f8a1b458baaf8e97a30a; path=/; secure; HttpOnly
                [x-runtime] => 0.307888
            )

        [response] => Array
            (
                [errors] => Error
            )

    )

[message:protected] => Internal Server Error
[string:Exception:private] => 
[code:protected] => 500
[file:protected] => /home/lolsmg/www/shopify_pinterest/shopify.php
[line:protected] => 32
[trace:Exception:private] => Array
    (
        [0] => Array
            (
                [file] => /home/lolsmg/www/shopify_pinterest/pintrest_ui.php
                [line] => 65
                [function] => {closure}
                [args] => Array
                    (
                        [0] => POST
                        [1] => /admin/custom_collections.json
                        [2] => Array
                            (
                                [custom_collection] => Array
                                    (
                                        [title] => ToddTest
                                        [collects] => Array
                                            (
                                                [product_id] => 96393246
                                            )

                                    )

                            )

                        [3] => Array
                            (
                                [http_status_message] => Internal Server Error
                                [http_status_code] => 500
                                [server] => nginx
                                [date] => Mon, 16 Jul 2012 23:23:45 GMT
                                [content-type] => application/json; charset=utf-8
                                [transfer-encoding] => chunked
                                [connection] => keep-alive
                                [status] => 500 Internal Server Error
                                [x-shopify-shop-api-call-limit] => 18/500
                                [http_x_shopify_shop_api_call_limit] => 18/500
                                [cache-control] => no-cache
                                [x-request-id] => f22337df8773ff4fa2f9f384ca21f133
                                [x-ua-compatible] => IE=Edge,chrome=1
                                [set-cookie] => _secure_session_id=50f46da87f21f8a1b458baaf8e97a30a; path=/; secure; HttpOnly
                                [x-runtime] => 0.307888
                            )

                    )

            )

    )

[previous:Exception:private] => 

) shopfiy が提供するサンプルコードから作業していますが、あまり進んでいません。助けてくれてありがとう。

4

1 に答える 1

1

ログを確認すると、「collects」属性は、実際には $charge 変数で指定した配列として送信されていないようです。request_id f22337df8773ff4fa2f9f384ca21f133 を調べた後、これが送信したリクエストです。

{"custom_collection"=>{"title"=>"ToddTest", "collects"=>{"product_id"=>96393246}}}

リクエストは次のようになります。

{"custom_collection"=>{"title"=>"ToddTest", "collects"=>[{"product_id"=>96393246}]}}

collects配列であることに注意してください。

于 2012-07-17T03:23:43.640 に答える