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.
With PHP, I use CURL.
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://{{store}}.myshopify.com/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;
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.