Home > Net >  how do i punctuate php curl statements
how do i punctuate php curl statements

Time:02-15

i am not profficeint in php when i encounter the term curl.

The below code apparently needs a correction.

curl_setopt($ch, CURLOPT_POSTFIELDS, {
"ShortCode": 600981,
"ResponseType": "Completed",
"ConfirmationURL": "https://mydomainx.com/confirmation",
"ValidationURL": "https://mydomainx.com/validation",
});

It gives an error

syntax error. unexpected '{' on the very first line. I will try any help offered.

CodePudding user response:

You can pass data as an array

$data = json_encode(array(
    "ShortCode" => "600981",
    "ResponseType" => "Completed",
    "ConfirmationURL" => "https://mydomainx.com/confirmation",
    "ValidationURL" => "https://mydomainx.com/validation",
));

curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  • Related