在curl_init()中将变量插入url时的语法

I need to insert an id-variable into the link "https://api.quickpay.net/payments/9727866/link" (instead of "9727866") but i can't seem to get the syntax right.

It doesn't seem to accept my variables no matter what I do.. anyone knows how to do this?

   $params = array(
       "amount"            => 100,
       "order_id"       => 999999
   );                                                                    
   $data_string = http_build_query($params, '&'); 

   $headers = array(
          'Accept-Version: v10',
          'Accept: application/json', 
          'Authorization: Basic ' . base64_encode(":HIDDEN_API_KEY")
      );                                                                                  

   $ch = curl_init('https://api.quickpay.net/payments/9727866/link');                                                                      
   curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");                                                                     
   curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);                                                                  
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);      
   curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);     
   curl_setopt($ch, CURLOPT_HEADER, true);
   curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

   $result = curl_exec($ch);

   if(!curl_exec($ch)){
       die('Error: "' . curl_error($ch) . '" - Code: ' . curl_errno($ch));
   }
   curl_close($ch);

   print_r($result);

It's probably because you're using single quotes. Try any of the following:

 $ch = curl_init("https://api.quickpay.net/payments/$variable/link"); 

or

$ch = curl_init("https://api.quickpay.net/payments/{$variable}/link");

or

$ch = curl_init("https://api.quickpay.net/payments/" . $variable . "/link");

or

$str = "https://api.quickpay.net/payments/" . $variable . "/link";
$ch = curl_init($str);

or

sprintf("https://api.quickpay.net/payments/%s/link", $variable);

Whatever floats your boat.