There are a few little things such as the SITE_URL being outside the brackets and the use of curl HTTPPOST. I tested the below request and it looks ok. Also ereg is depreciated so I switched that out.
function registerShopifyAppUninstallWebhook($shop_domain, $access_token){ $API_KEY = SHOPIFY_API_KEY; $SECRET = SHOPIFY_SHARED_SECRET; $TOKEN = $access_token; $STORE_URL = $shop_domain; $url = 'https://'; . $STORE_URL . '/admin/webhooks.json'; $params = '{"webhook": {"topic": "app/uninstalled","address": "'.SITE_URL.'users/setShopifyUninstall","format": "json" }}'; $session = curl_init(); curl_setopt($session, CURLOPT_URL, $url); curl_setopt($session, CURLOPT_POST, 1); // Tell curl that this is the body of the POST curl_setopt($session, CURLOPT_POSTFIELDS, $params); curl_setopt($session, CURLOPT_HEADER, false); curl_setopt($session, CURLOPT_HTTPHEADER, array('Accept: application/json', 'Content-Type: application/json', 'X-Shopify-Access-Token: '.$TOKEN)); curl_setopt($session, CURLOPT_RETURNTRANSFER, true); if(preg_match("/^(https)/",$url)) curl_setopt($session,CURLOPT_SSL_VERIFYPEER,false); $response = curl_exec($session); curl_close($session); $body =json_decode($response); if($body) return $body; else return "0"; }
Also I just looked at what request libraries are available for cake as using curl is very messy and leads to issues. It looks like it has a built in HttpSocket
http://book.cakephp.org/2.0/en/core-utility-libraries/httpsocket.html