Hoping someone can help me. I can’t get any of the shopify API libraries to work. Because it’s private, I don’t have to do the authentification stuff (so should be easier.) My code below works when I change it to retrieve a list of products, but when I try to add a new one, I get a “Required parameter missing” error. Yet the documentation says all I need is a title and a type.
Any ideas? Thanks!
$adb_url="https://<myapikey>:<myapisecret>@<myurl>.myshopify.com/admin";
$adb_option_defaults = array(
CURLOPT_HEADER => false,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 2
);
// ArangoDB REST function.
// Connection are created demand and closed by PHP on exit.
function adb_rest($method,$uri,$querry=NULL,$json=NULL,$options=NULL){
global $adb_url,$adb_handle,$adb_option_defaults;
// Connect
if(!isset($adb_handle)) $adb_handle = curl_init();
// Compose querry
$options = array(
CURLOPT_URL => $adb_url.$uri."?".$querry,
CURLOPT_CUSTOMREQUEST => $method, // GET POST PUT PATCH DELETE HEAD OPTIONS
CURLOPT_POSTFIELDS => $json,
);
curl_setopt_array($adb_handle,($options + $adb_option_defaults));
// send request and wait for responce
$responce = json_decode(curl_exec($adb_handle),true);
echo "Responce from DB: \
";
print_r($responce);
return($responce);
}
$responce = adb_rest("POST","/products.json","",'{
"product": {
"title": "Burton Custom Freestlye 151",
"product_type": "Food"
');
var_dump($responce);