Focuses on API authentication, access scopes, and permission management.
I can read products and delete products but I cannot create or update.
I'm using the phpclassic/shopifysdk
I've checked the json and it's valid, I'm totally stuck
public function __construct()
{
$config = array(
"ShopUrl" => $_ENV["SHOPIFY_SHOP_URL"],
"AccessToken" => $_ENV["SHOPIFY_ACCESS_TOKEN"],
"Curl" => array(
CURLOPT_TIMEOUT => 10,
CURLOPT_FOLLOWLOCATION => true
)
);
$this->shopify = new ShopifySDK($config);
}
public function apiAddProduct($data) : void
{
$jsonData = json_encode($data, JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT);
try {
$response = $this->shopify->Product->post($jsonData);
error_log("Response: " . print_r($response, true));
} catch (CurlException $e) {
$this->addError("product", $e->getMessage());
error_log("CurlException: " . $e->getMessage());
} catch (\Exception $e) {
$this->addError("product", $e->getMessage());
error_log("Exception: " . $e->getMessage());
}
}
Every time i try to submit the data I get a 400 response, with no other details or errors.
Hi Rich,
Since this is a 3rd party SDK I'd recommend opening an issue in the repo here: https://github.com/phpclassic/php-shopify/issues
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog