的file_get_contents和电报API(reply_markup)
问题描述:
我想做出发送带有按钮这样的file_get_contents和电报API(reply_markup)
命令,所以我做这个
$url = "https://api.telegram.org/" . $token . "/sendMessage?chat_id=" . $message_chat_id . "&text=" . urlencode($message_text) . '&reply_markup={"inline_keyboard":[[{"text":"Visualizza spoiler!","url":"http://google.com/"}]]}';
,它使这个网址
https://api.telegram.org/censored/sendMessage?chat_id=censored&text=%2Fspoiler+ciao&reply_markup={"inline_keyboard":[[{"text":"Visualizza spoiler!","url":"http://google.com/"}]]}
当我在浏览器中使用这个网址它的作品,但是当我使用file_get_contents它不是
有人可以帮助我吗?
答
前几天我有同样的问题,我只是尝试卷曲,而它的工作。
function curl_get_contents($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
你试过CURL吗?那是什么版本的PHP?你有没有检查服务器上是否启用了file_get_contents? – wast
nop,因为直到现在我用了file_get_contents; php5.6;是的,这是启用,因为如果我想发送一个简单的消息,它的作品 – Dekus
你可以尝试简单的卷曲? https://stackoverflow.com/questions/7794604/file-get-contents-not-working – wast