卷曲到PHP代码

I have the following code :

 curl -X PUT -u "<app key>:<secret key>" \
    -H "Content-Type: application/json" \
    --data '{"alias": "myalias"}' \
    https://go.xxx.com/api/device_tokens/<token>/

I tried to convert it to php but it seems not working and i don't know what is the problem.

this is what i tried

    <?
       $token = $_POST["token"];
       $al =  $_POST["alias"];
       exec('curl -X PUT -u "_rEUqXXXmSVEBXXuMfdtg:vpB2XXXXX_2HZ_XXXX7t-Q" \
         -H "Content-Type: application/json" \
         --data \'{"alias": "'.$al.'"}\' \
         https://go.xxx.com/api/device_tokens/'.$token'/');
?>
    $ch = curl_init();
    // echo $url; die;
    curl_setopt($ch, CURLOPT_URL,$url);
    curl_setopt($ch, CURLOPT_POST, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("custom: header")); 
    $returned = curl_exec($ch);
    curl_close ($ch);

There are many more options to do what you want in the PHP docs, don't they help.