Why am I getting an error with my custom API in PHP?

Solved

Why am I getting an error with my custom API in PHP?

chandrakantb36
Shopify Partner
4 0 1

Hi,

 

I have developed PHP api code for getting an orders list but getting error {"errors":"Not Found"}

 

Code

 

 

$API_KEY = '******************************';
$PASSWORD = '******************************';
$STORE_URL = '*********.myshopify.com';

$url = 'https://' . $API_KEY . ':' . $PASSWORD . '@' . $STORE_URL . '/admin/api/2022-09/orders.json?status=any';
$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');


$headers = array();
$headers[] = 'Content-Type: application/json';
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); //can check status code, requst successfully processed if return 200
if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
echo $result;

 

 

Please help me.

Accepted Solution (1)

Kani
Shopify Partner
468 125 232

This is an accepted solution.

Hi  @chandrakantb36 

 

change it to '2022-07'   https://shopify.dev/api/admin-rest

Kani_1-1662954606991.png

 

Kani_0-1662954590967.png

 

Hey!! ʕ ᵔᴥᵔ ʔ
Please click 'Like' and ' Accept as Solution' to encourage me to continue sharing my expertise. ♡
If you need any technical assistance, feel free to send me a DM. You no longer have to search for answers without getting a response. 🙂

View solution in original post

Reply 1 (1)

Kani
Shopify Partner
468 125 232

This is an accepted solution.

Hi  @chandrakantb36 

 

change it to '2022-07'   https://shopify.dev/api/admin-rest

Kani_1-1662954606991.png

 

Kani_0-1662954590967.png

 

Hey!! ʕ ᵔᴥᵔ ʔ
Please click 'Like' and ' Accept as Solution' to encourage me to continue sharing my expertise. ♡
If you need any technical assistance, feel free to send me a DM. You no longer have to search for answers without getting a response. 🙂