-1

我是 Shopify 应用程序和 Guzzle 的新手,并已按照https://www.sitepoint.com/shopify-app-development-made-simple/开始使用 shopify 应用程序。但现在无法创建产品/客户。我使用过的代码:

                <?php
            require 'vendor/autoload.php';

            use GuzzleHttp\Client;

            $dotenv = new Dotenv\Dotenv(__DIR__);
            $dotenv->load();

            $db = new Mysqli(getenv('MYSQL_HOST'), getenv('MYSQL_USER'), getenv('MYSQL_PASS'), getenv('MYSQL_DB')); 

            $store = 'customboxes1.myshopify.com'; 
            $select = $db->query("SELECT access_token FROM installs WHERE store = '$store'");
            $user = $select->fetch_object();
            $access_token = $user->access_token;
            $customerData = array
                    (
                        "customer" => array(
                            "first_name"    =>  "Steve",
                            "last_name"     =>  "Lastnameson",
                            "email"         =>  "steve.lastnameson10@test.com",
                            "verified_email"=>  true,
                        )
                    );
            $client = new Client();

            $response = $client->request(
                'POST', 
                "https://{$store}/admin/customers.json",
                [
                    'query' => [
                        'fields' => $customerData,
                        'access_token' => $access_token
                    ]
                ]
            );

            $result = json_decode($response->getBody()->getContents(), true);
            echo $result;
4

1 回答 1

-1
POST /admin/products.json
{
  "product": {
    "title": "Burton Custom Freestyle 151",
    "body_html": "<strong>Good snowboard!<\/strong>",
    "vendor": "Burton",
    "product_type": "Snowboard",
    "tags": "Barnes & Noble, John's Fav, \"Big Air\""
  }
}

在这段代码中使用它

$client = 新客户();

$response = $client->request(
    'POST', 
    "https://{$store}/admin/products.json/access_token",
    [
        'form_params' => [
            'client_id' => $api_key,
            'client_secret' => $secret_key,
            'code' => $query['code']
        ]
    ]
);
于 2017-07-07T08:22:55.767 回答