问题使用电报中的URL创建keyboard
inline_keyboard
当我使用“&”时在地址网址中,keyboard
没有创建电报?!!!!!!!
此代码有效:
$text = "server=164.132.117.18\nport=8585\nsecret=c53a3eae90544e68a37cbe41c5d31442";
$keyboard = array(
'resize_keyboard' => true,
'inline_keyboard' => array(
array(
array('text' => "Click for Connect", 'url' => "https://t.me/proxy?server=164.132.117.18port=8585secret=c53a3eae90544e68a37cbe41c5d31442")
)
)
);
$url = API_URL_KEY . "sendMessage?chat_id=" . CHAT_ID_USER . "&text=" . urlencode($text). "&reply_markup=" . json_encode($keyboard);
$ch = curl_init();
$optArray = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $optArray);
curl_exec($ch);
curl_close($ch);
但是,这段代码不起作用:
$text = "server=164.132.117.18\nport=8585\nsecret=c53a3eae90544e68a37cbe41c5d31442";
$keyboard = array(
'resize_keyboard' => true,
'inline_keyboard' => array(
array(
array('text' => "Click for Connect", 'url' => "https://t.me/proxy?server=164.132.117.18&port=8585&secret=c53a3eae90544e68a37cbe41c5d31442")
)
)
);
$url = API_URL_KEY . "sendMessage?chat_id=" . CHAT_ID_USER . "&text=" . urlencode($text). "&reply_markup=" . json_encode($keyboard);
$ch = curl_init();
$optArray = array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true
);
curl_setopt_array($ch, $optArray);
curl_exec($ch);
curl_close($ch);
有没有人有解决方案?
答案 0 :(得分:0)
尝试拨打您构建的网址时收到的错误代码为400 "Bad Request: can't parse reply keyboard markup JSON object"
。
尝试urlencode()
$keyboard
中找到的网址部分。
$keyboard = array(
'resize_keyboard' => true,
'inline_keyboard' => array(
array(
array('text' => "Click for Connect", 'url' => urlencode("https://t.me/proxy?server=164.132.117.18&port=8585&secret=c53a3eae90544e68a37cbe41c5d31442"))
)
)
);
这应该有用。