Shopify API - 使用PHP在商店中获取折扣代码

With a Shopify API call I am able to get the product data, but I need a way to get the discount codes available in the store.

I need the script in PHP. Does anyone have an idea of how I can achieve this?

Maybe these similar questions will help you get started:

The first 2 links above mention this project on GitHub. It provides an example you might be able to use:

require 'shopify.php';
$api = new \Shopify\PrivateAPI('username', 'password', 'https://mystore.myshopify.com/admin');

...

$discounts = $api->doRequest('GET', 'discounts.json', $params);
if (isset($discounts->discounts)) {
    $coupons = $discounts->discounts;
    foreach ($coupons as $coupon) {
        print_r($coupon);
    }
}