gpt4 book ai didi

php - 我可以将 PHP 变量插入 JSON 字符串吗?

转载 作者:行者123 更新时间:2023-12-02 01:22:24 25 4
gpt4 key购买 nike

我正在使用 REST API 将属性 POST 给使用 json 的人。我的请求正文如下所示:

$requestBody = '

{
"attribute": {
"@id": "",
"@uri": "",
"person": {
"@id": "222",
"@uri": "https://api_name_removed.com/v1/People/222"
},
"attributeGroup": {
"@id": "",
"@uri": "",
"name": null,
"attribute": {
"@id": "2404",
"@uri": "",
"name": null
}
},
"lastUpdatedDate": null
}
}';

如何将人员 id、人员 uri 和属性 id 更改为我已存储的变量?

最佳答案

$requestBody = '

{
"attribute": {
"@id": "' . $id . '",
"@uri": "' . $uri . '",
"person": {
"@id": "222",
"@uri": "https://api_name_removed.com/v1/People/222"
},
"attributeGroup": {
"@id": "",
"@uri": "",
"name": null,
"attribute": {
"@id": "2404",
"@uri": "",
"name": null
}
},
"lastUpdatedDate": null
}
}';

关于php - 我可以将 PHP 变量插入 JSON 字符串吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2256307/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com