1

我正在使用 Sandeep Shetty 的 PHP 适配器 (https://github.com/sandeepshetty/shopify.php) 并尝试添加 Collection。这是代码:

define( 'SHOPIFY_DOMAIN', 'domain.myshopify.com');
define( 'SHOPIFY_API_KEY', 'API KEY');
define( 'SHOPIFY_API_PASS', 'PASS HERE');
define( 'SHOPIFY_SECRET', 'SECRET HERE');

require 'shopify/shopify.php';


// For regular apps:
$shopify = shopify_api_client(SHOPIFY_DOMAIN, NULL, SHOPIFY_API_KEY, SHOPIFY_API_PASS, true);

// For private apps:
// $shopify = shopify_api_client($shops_myshopify_domain, NULL, $api_key, $password, true);
try
{
    // Get all products
//        $products = $shopify('GET', '/admin/products.json', array('published_status'=>'published'));


    // Create a new recurring charge
    $charge = array
    (
        "custom_collection"=>array
        (
            "title"=>"IPods",
            "collects"=>array(
                                "product_id"=>99395362
                            )
        )
    );

    try
    {
        // All requests accept an optional fourth parameter, that is populated with the response headers.
        $recurring_application_charge = $shopify('POST', '/admin/custom_collections.json', $charge, $response_headers);
//            pr($response_headers);
//            pr($recurring_application_charge);
        // 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)
    {
        pr($e);
        // If you're here, either HTTP status code was >= 400 or response contained the key 'errors'
    }

}
catch (ShopifyApiException $e)
{
//        $err = $e->getInfo();
    pr($e);
    /* $e->getInfo() will return an array with keys:
        * method
        * path
        * params (third parameter passed to $shopify)
        * response_headers
        * response
        * shops_myshopify_domain
        * shops_token
    */
}
catch (ShopifyCurlException $e)
{
    pr($e);
    // $e->getMessage() returns value of curl_errno() and $e->getCode() returns value of curl_ error()
}

当我运行上面的代码时。我收到带有 http_status_message 的 ShopifyApiException 错误] => 内部服务器错误 [http_status_code] => 500

这是供参考的完整阵列响应。

ShopifyApiException Object
(
[info:protected] => Array
    (
        [method] => POST
        [path] => /admin/custom_collections.json
        [params] => Array
            (
                [custom_collection] => Array
                    (
                        [title] => IPods
                        [collects] => Array
                            (
                                [product_id] => 99395362
                            )

                    )

            )

        [response_headers] => Array
            (
                [http_status_message] => Internal Server Error
                [http_status_code] => 500
                [server] => nginx
                [date] => Sat, 15 Sep 2012 18:56:36 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] => 1/500
                [http_x_shopify_shop_api_call_limit] => 1/500
                [cache-control] => no-cache
                [x-request-id] => f6fdb72b6cabf22a73207d82b8ea16d9
                [x-ua-compatible] => IE=Edge,chrome=1
                [set-cookie] => _secure_session_id=cf2648422369ee231220b6f1f1efdb3b; path=/; secure; HttpOnly
                [x-runtime] => 0.047004
            )

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

    )

[message:protected] => Internal Server Error
[string:Exception:private] => 
[code:protected] => 500
[file:protected] =>PATH.TO.FILE\shopify\shopify.php
[line:protected] => 28
[trace:Exception:private] => Array
    (
        [0] => Array
            (
                [file] => PATH.TO.FILE\index.php
                [line] => 44
                [function] => {closure}
                [args] => Array
                    (
                        [0] => POST
                        [1] => /admin/custom_collections.json
                        [2] => Array
                            (
                                [custom_collection] => Array
                                    (
                                        [title] => IPods
                                        [collects] => Array
                                            (
                                                [product_id] => 99395362
                                            )

                                    )

                            )

                        [3] => Array
                            (
                                [http_status_message] => Internal Server Error
                                [http_status_code] => 500
                                [server] => nginx
                                [date] => Sat, 15 Sep 2012 18:56:36 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] => 1/500
                                [http_x_shopify_shop_api_call_limit] => 1/500
                                [cache-control] => no-cache
                                [x-request-id] => f6fdb72b6cabf22a73207d82b8ea16d9
                                [x-ua-compatible] => IE=Edge,chrome=1
                                [set-cookie] => _secure_session_id=cf2648422369ee231220b6f1f1efdb3b; path=/; secure; HttpOnly
                                [x-runtime] => 0.047004
                            )

                    )

            )

    )

[previous:Exception:private] => 
)

请指导我在这里做错了什么:谢谢

4

0 回答 0