从下面的代码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,
)
);
$options = [
'http' => [
'header' => [ "Content-Type: application/json", $authHeader ],
'method' => 'POST',
'content' => json_encode([
"messages" => [
[
"content" => "Hello",
"destination" => "0718860000",
],
],
]),
),
);