php - Proper shopify api product create -


i trying create product shopify api product not set , getting no errors. print_r($server_output); displays nothing can't see wrong. curl enabled. below code use.
when print_r($products); displays array how should. doing wrong?

$name='test product 555'; $group=36; $quantity=20; $price='20.95';  $url = 'https://my_key_and_pass/admin/products.json'; $type = 'post'; $product = array('title' => utf8_encode($name),         'body_html' => utf8_encode($name),         'product_type'=> $group,         'variants' => array(         array('price' => $price,         'inventory_quantity'=> $quantity,         'inventory_management' => 'shopify'         )         )         );  $ch = curl_init($url); $data_string = json_encode(array('product'=>$product));         curl_setopt($ch, curlopt_customrequest, $type);         curl_setopt($ch, curlopt_postfields, $data_string);         curl_setopt($ch, curlopt_returntransfer, true);         curl_setopt($ch, curlopt_httpheader, array(         'content-type: application/json',         'content-length: ' . strlen($data_string))         ); $server_output = curl_exec ($ch); print_r($server_output); curl_close ($ch); 

i'm not familiar php/curl, might missing post field count:

curl_setopt($ch, curlopt_post, count($data_string)); 

or

curl_setopt($ch, curlopt_post, 1); 

since have 1 product.

have tried in app postman? work there?


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

c# - Retrieve google contact -

javascript - How to insert selected radio button value into table cell -