我面临的问题可能看起来很简单,但是由于我无法尝试,因此变得很麻烦。
我需要将数据发布到 API。我正在使用 cURL PHP 执行此操作,因此我从表单中获取数据,将其存储在变量中,并将这些变量存储在要发送的数组中,但我需要发送的参数之一是数组本身:
此信息旨在描述客户:
"administrative": false,
"alias_numbers": [
{
"ac": "858",
"cc": 34,
"number_id": 3161,
"sn": "880961"
},
{
"ac": "958",
"cc": 34,
"number_id": 3239,
"sn": "514"
},
{
"ac": "465",
"cc": 34,
"number_id": 3241,
"sn": "363983"
},
{
"ac": "858",
"cc": 34,
"number_id": 3243,
"sn": "88085692"
},
{
"ac": "951",
"cc": 34,
"number_id": 3245,
"sn": "598217"
}
],
"customer_id": 1,
我不确定如何将 alias_numbers 分配给我的 dataArray 中的值,最多可以有 10 个,但这是在表单中控制的。这就是我想出的:
$dataArray = array(
"customer_id" => $subscriberCustomerId,
"email" => $subscriberEmail,
"username" => $subscriberComRegNum,
"external_id" => $subscriberComRegNum,
"primary_number" => array(
"cc" => $subscriberPrimaryNumber["cc"],
"ac" => $subscriberPrimaryNumber["ac"],
"sn" => $subscriberPrimaryNumber["sn"]
),
for ($i=0; $i < sizeof($arrayAliasNumbers); $i++) {
"alias_numbers" => array(
"cc" => $arrayAliasNumbers[$i]["cc"],
"ac" => $arrayAliasNumbers[$i]["ac"],
"sn" => $arrayAliasNumbers[$i]["sn"]
),
}
"domain_id" => $subscriberDomainId,
"administrative" => $subscriberAdministrative,
"status" => $subscriberStatus
);
您可以看到有一个 primary_number 没有造成任何麻烦,因为只能有一个,但是有了这些别名,我完全迷失了。
吃鸡游戏