Post Shopify API

Click here for detailed explanation and download the full code.

create-blogs-shopify-api
Export Import blogs Shopify api full code.

public function postContents( $dataArray, $postUrl ) {
        
    try{

        $requestJson = json_encode( $dataArray );
        $postlength = strlen($requestJson);
        $ch = curl_init();
        curl_setopt($ch,CURLOPT_URL,$postUrl);
        curl_setopt($ch,CURLOPT_POST,$postlength);
        curl_setopt($ch,CURLOPT_POSTFIELDS,$requestJson);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
        $response = curl_exec($ch);
        curl_close($ch);
        return $response;

    } catch (Exception $ex) {
            echo 'Post data error: ' . $ex->getMessage();
    } 
}

Share this Tutorial