fork download
  1. <?php
  2.  
  3. $store = 'saasintegration'; // ✅ Replace with your actual store name
  4. $token = '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'; // ✅ Shopify Admin API token
  5.  
  6. $endpoint = "https://{$store}.myshopify.com/admin/api/2025-01/graphql.json";
  7.  
  8. $query = <<<GQL
  9. {
  10.   customers(first: 10) {
  11.   edges {
  12.   node {
  13.   id
  14.   email
  15.   firstName
  16.   lastName
  17.   metafield(namespace: "rivo", key: "points") {
  18.   value
  19.   }
  20.   }
  21.   }
  22.   }
  23. }
  24. GQL;
  25.  
  26. $data = ['query' => $query];
  27.  
  28. $ch = curl_init($endpoint);
  29. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  30. curl_setopt($ch, CURLOPT_POST, true);
  31. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
  32. curl_setopt($ch, CURLOPT_HTTPHEADER, [
  33. 'Content-Type: application/json',
  34. 'X-Shopify-Access-Token: ' . $token,
  35. ]);
  36.  
  37. $response = curl_exec($ch);
  38.  
  39. if (curl_errno($ch)) {
  40. echo 'Curl error: ' . curl_error($ch);
  41. } else {
  42. echo "Response:\n";
  43. print_r(json_decode($response, true));
  44. }
  45.  
  46.  
Success #stdin #stdout 0.04s 26428KB
stdin
Standard input is empty
stdout
Curl error: Could not resolve host: saasintegration.myshopify.com