[英]Shopify REST API - how to connect?
Seems like a simple task but despite having read their docs I can't figure it out. 似乎是一个简单的任务,但是尽管阅读了文档,但我还是无法弄清楚。 I've gotten a Storefront Access Token, as per https://help.shopify.com/en/api/storefront-api/getting-started .
根据https://help.shopify.com/en/api/storefront-api/getting-started ,我已经获得了一个店面访问令牌。 Then I've used it in the CURL request below.
然后,我在下面的CURL请求中使用了它。 However this just returns: {"errors":"[API] Invalid API key or access token (unrecognized login or wrong password)"}
但是,这仅返回:{“错误”:“ [API]无效的API密钥或访问令牌(无法识别的登录名或错误的密码)”}
I found their documentation a bit confusing as they have quite a few different APIs, and whilst it seems that this Storefront Access Token should work for this particular API, perhaps it doesn't? 我发现他们的文档有些混乱,因为它们有许多不同的API,尽管此Storefront Access Token似乎应该适用于此特定API,但也许不是吗?
$url = "https://mysite.myshopify.com/admin/api/2019-07/products/count.json";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
$headers = array(
'X-Shopify-Storefront-Access-Token: 2400d...........a999'
);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
print_r( $result);
curl_close($ch);
If you are using the Stronfront API your request should point to 如果您使用的是Stronfront API,则您的请求应指向
https://mysite.myshopify.com/api/2019-07/products/count.json
and not to 而不是
https://mysite.myshopify.com/admin/api/2019-07/products/count.json
In addition Storefront Api request are different from the standard ones, have that in mind. 另外,请记住Storefront Api的请求与标准请求不同。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.