【发布时间】:2023-03-30 06:59:01
【问题描述】:
我试图在多维 JSON 字符串中包含一个变量。我想我需要使用 json_encode 但我不知道该怎么做。
$clientID = 123456;
$body = "<h1 id='heading1'>This is just a standard html message.</h1>";
curl_setopt($ch, CURLOPT_POSTFIELDS, "{
\"subject\": \"How Did We Do\",
\"clientId\": $clientID,
\"assignedUserId\": 2988,
\"public\": false,
\"activity\": [
{
\"public\": false,
\"comment\": {
\"body\": $body
}
}
]
}");
【问题讨论】:
-
为什么要手动创建一个json字符串?
-
对于 API 调用,我不知道其他方式。