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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

Based 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