post request to API not working with oauth token

Highlighted
New Member
3 0 0

 

I am attempting to make my 1st request to shopify API. Below is code with token removed for security. (ERROR is [API] Invalid API key or access token (unrecognized login or wrong password))
 
What am I doing wrong?
 
 
$token = 'TOKEN';
$data['product'] = array(
'title' => 'Burton Custom Freestyle 151',
'body_html' => '<strong>Good snowboard!</strong>',
);
 
$ch = curl_init($url);  
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");                                                                     
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));                                                                  
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);   
//Don't verify ssl...just in case a server doesn't have the ability to verify
$headers = array(  
   'X-Shopify-Access-Token: '.$token,                                                                                
);
 
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
 
    $return = json_decode(curl_exec($ch)); 
  
  var_dump($return);

 

0 Likes