2017-10-14 52 views
-1

我想做出發送帶有按鈕這樣的file_get_contents和電報API(reply_markup)

open me plz

命令,所以我做這個

$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它不是

有人可以幫助我嗎?

+0

你試過CURL嗎?那是什麼版本的PHP?你有沒有檢查服務器上是否啓用了file_get_contents? – wast

+0

nop,因爲直到現在我用了file_get_contents; php5.6;是的,這是啓用,因爲如果我想發送一個簡單的消息,它的作品 – Dekus

+0

你可以嘗試簡單的捲曲? https://stackoverflow.com/questions/7794604/file-get-contents-not-working – wast

回答

0

前幾天我有同樣的問題,我只是嘗試捲曲,而它的工作。

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; 
}