0

从下面的代码 2 通过 $sendData 引用代码 2。我想完全删除代码 1,并且只使用代码 2。我可以帮助我将代码 1 写入代码 2,也许以数组的形式

代码 1

$sendData = '{ "messages" : [ { "content" :  "Hello", "destination" : "0718860000" } ] }';

代码 2

$options = array(
    'http' => array(
        'header'  => array("Content-Type: application/json", $authHeader),
        'method'  => 'POST',
        'content' => $sendData,
    )
);
4

1 回答 1

1
$options = [
    'http' => [
        'header'  => [ "Content-Type: application/json", $authHeader ],
        'method'  => 'POST',
        'content' => json_encode([
            "messages" => [
                [ 
                    "content" => "Hello",
                    "destination" => "0718860000",
                ],
            ],
        ]),
    ),
);
于 2021-08-14T08:27:18.520 回答