我需要將資料從 varlable saved1 傳遞到 reply_message (第 45 行),但它不起作用
我試過 " {"text": "${saved1}"} 但沒有任何反應。
預期的結果是 "text": "line1 \n 123 \n line 3"
輸出
1號線
123
3號線
任何幫助表示感謝感謝和問候
<?php
send_reply($access_token,$reply_message);
$reply_message='{
"messaging_type": "RESPONSE",
"recipient": {
"id": "1631126643573991"
},
"message": {
"text": "line1 \n $saved1 \n line 3"
}
}';
send_reply($access_token,$reply_message);
}
function send_reply($access_token='',$reply='')
{
$url="https://graph.facebook.com/v14.0/me/messages?access_token=$access_token";
$ch = curl_init();
$headers = array("Content-type: application/json");
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$reply);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$st=curl_exec($ch);
$result=json_decode($st,TRUE);
return $result;
}
?>
uj5u.com熱心網友回復:
對 $saved1 使用串聯,如下所示。
$reply_message='{
"messaging_type": "RESPONSE",
"recipient": {
"id": "1631126643573991"
},
"message": {
"text": "line1 \n '.$saved1.' \n line 3"
}
}';
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/505183.html
