admin管理员组文章数量:1320661
I'm trying to create a simple app that reads our stores products, contacts an external API to get stock levels then update our stores products with the new stock levels how ever encountering alot of issues..
The examples for the graphQL library for php seems to be a bit strange, says i need to authenticate my app using auth0 which will give me a session token and allow me to query then my shopify store using graphQL however that seems strange to me?
This app will be completely headless.. will be run on a cron job so why would i need to authenticate? Isn't that what my stores api key and access token is for?
Anyway i tried to then make a request to my store https://XXXXXX/admin/api/2025-01/graphql.json
with the X-Shopify-Access-Token in the headers and i get a curl error " cURL error 6: Could not resolve host: login"
if i try visit that url in my browser a login box prompts for a username and password?
Any help would be appreciated, thanks.
I'm trying to create a simple app that reads our stores products, contacts an external API to get stock levels then update our stores products with the new stock levels how ever encountering alot of issues..
The examples for the graphQL library for php seems to be a bit strange, says i need to authenticate my app using auth0 which will give me a session token and allow me to query then my shopify store using graphQL however that seems strange to me?
This app will be completely headless.. will be run on a cron job so why would i need to authenticate? Isn't that what my stores api key and access token is for?
Anyway i tried to then make a request to my store https://XXXXXX/admin/api/2025-01/graphql.json
with the X-Shopify-Access-Token in the headers and i get a curl error " cURL error 6: Could not resolve host: login"
if i try visit that url in my browser a login box prompts for a username and password?
Any help would be appreciated, thanks.
Share Improve this question asked Jan 18 at 16:09 Barry WhiteBarry White 295 bronze badges1 Answer
Reset to default 0Based on what I read, I can assume that you are doing a direct integration with the API.
With PHP, I use CURL.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://{{store}}.myshopify/admin/api/2025-01/graphql.json',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"query": "mutation {}"
}',
CURLOPT_HTTPHEADER => array(
'X-Shopify-Access-Token: {{token}}',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
To build the GraphQL queries, I use the GraphQL Shopify App/Playground: API:https://shopify.dev/graphiql/admin-graphiql
This response is based on the assumption that you are using a custom app (Developer App) and that you have already granted the necessary permissions to it.
本文标签: Issues with shopify API and graphQLStack Overflow
版权声明:本文标题:Issues with shopify API and graphQL - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742065634a2418817.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论