I'm making a script to be run by a cronjob.
It's suppossed to fetch some json orders and process them.
My script at the moment looks like this:
$json_string = '/admin/orders/7109.json';
$real_url = "https://my-store.myshopify.com{$json_string}";
$user = 'my-user';
$pass = 'my-pass';
$ch = curl_init($real_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $user . ':' . $pass);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
$result = json_decode(curl_exec($ch),true);
curl_close($ch);
file_put_contents(__DIR__ . '/../debug/tracker_test.txt', print_r($result,true));
I'm getting this written into the code file even tho my credentials are correct.
Array
(
[errors] => [API] Invalid API key or access token (unrecognized login or wrong password)
)
Am I missing something ?
Edit: In the private apps section of Shopify it gives an example url format:
https://apikey:password@hostname/admin/resource.json
So now the script looks like this:
$json_url = 'https://my-api-key:my-api-pass@my-store.myshopify.com/admin/orders.json';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $real_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
$result = json_decode(curl_exec($ch), true);
curl_close($ch);
but I'm still getting the same error.