0

i want to pass $var[5] in to the {subscription_reference} in the url.$var[5] contains string value.

Here is my code

$url5 = $api_entry_point ."/subscription/{subscription_reference}/credentials";


    $ch5 = curl_init($url5);
    curl_setopt($ch5, CURLOPT_USERPWD, "{$user}:{$pass}");
    curl_setopt($ch5, CURLOPT_GET, 1);
    curl_setopt($ch5, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch5, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch5, CURLOPT_RETURNTRANSFER, 1);
    $output5 = curl_exec($ch5);
    curl_close($ch5);
    var_dump($output5);

Here are the various ways i followed and gone wrong.

$url5 = $api_entry_point ."/subscription/'.$var[5].'/credentials";

$url5 = $api_entry_point ."/subscription/![CDATA[".$var[5]."]]/credentials";

$url5 = $api_entry_point ."/subscription/$var[5]/credentials";
colombo
  • 520
  • 2
  • 9
  • 24

1 Answers1

0

If it's a get request just put the parameters after the link with ?param1=param&param2=param2 etc etc.

If the request is post you will need to use:

curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));

Where $params is an array with your parameters.

Vasil Rashkov
  • 1,818
  • 15
  • 27