2017-10-22 9 views
1

URL로 AnswerInlineQuery를 만들려면 어떻게해야합니까?URL로 답변 인라인 쿼리를 만들 수있는 방법

$data = array(); 
$data['inline_query_id']= $inline_query_id;//sample : 1515027006022511114 
$data['results']='[ 
    { 
    "type": "article", 
    "id": "001", 
    "title": "UC Browser", 
    "message_text": "Text of the first message", 
    "parse_mode": "Markdown", 
    "disable_web_page_preview": true, 
    "url": "telegram.com", 
    "hide_url": true, 
    "description": "Optional. Short description of the result", 
    "thumb_url": "http://icons.iconarchive.com/icons/martz90/circle/64/uc-browser-icon.png", 
    "thumb_width": 64, 
    "thumb_height": 64 
    }, 
    { 
    "type": "article", 
    "id": "002", 
    "title": "Bitcoin", 
    "message_text": "*Text of the second message*", 
    "parse_mode": "Markdown", 
    "disable_web_page_preview": true, 
    "url": "bitcoin.org", 
    "hide_url": true, 
    "description": "Short description of the result", 
    "thumb_url": "http://www.coinwarz.com/content/images/bitcoin-64x64.png", 
    "thumb_width": 64, 
    "thumb_height": 64 
    } 
]'; 

$ch = curl_init(); 
$curlConfig = array(
    CURLOPT_URL => 'https://api.telegram.org/bot' . TOKEN . '/answerInlineQuery', 
    CURLOPT_POST => true, 
    CURLOPT_RETURNTRANSFER => true, 
    CURLOPT_SAFE_UPLOAD => true, 
    CURLOPT_POSTFIELDS => 'params=' . json_encode($data), 
    CURLOPT_VERBOSE => true, 
); 
curl_setopt_array($ch, $curlConfig); 
$result = curl_exec($ch); 
curl_close($ch); 

그러나 결과 : 그 쿼리에 대한 자세한 내용을 찾을 수없는, 모든 샘플 코드는 전보 SDK에 대해, 나는 (클래스가 아닌 URL 게시물을)

나는이 시도 같은 코드 필요 입니다 :

Result : {"ok":false,"error_code":400,"description":"Bad Request: QUERY_ID_INVALID"} 

와 나도이 시도 :

$mResult = '[ 
     { 
     "type": "article", 
     "id": "001", 
     "title": "UC Browser", 
     "message_text": "Text of the first message", 
     "parse_mode": "Markdown", 
     "disable_web_page_preview": true, 
     "url": "telegram.com", 
     "hide_url": true, 
     "description": "Optional. Short description of the result", 
     "thumb_url": "http://icons.iconarchive.com/icons/martz90/circle/64/uc-browser-icon.png", 
     "thumb_width": 64, 
     "thumb_height": 64 
     }, 
     { 
     "type": "article", 
     "id": "002", 
     "title": "Bitcoin", 
     "message_text": "*Text of the second message*", 
     "parse_mode": "Markdown", 
     "disable_web_page_preview": true, 
     "url": "bitcoin.org", 
     "hide_url": true, 
     "description": "Short description of the result", 
     "thumb_url": "http://www.coinwarz.com/content/images/bitcoin-64x64.png", 
     "thumb_width": 64, 
     "thumb_height": 64 
     } 
    ]'; 
$url= "https://api.telegram.org/bot" . TOKEN . "/answerInlineQuery?inline_query_id=" . $inline_query_id . "&results=" . json_encode($mResult); 
file_get_contents($url); 

을이 반환 :

Result : {"ok":false,"error_code":400,"description":"Bad Request: QUERY_ID_INVALID"} 

답변

1

이 시도 :

$mResult = [ 
    [ 
     "type" => "article", 
     "id" => "first", 
     "title" => "Hey", 
     "message_text" => "Hello World", 
     "parse_mode" => "Markdown", 
    ] 
]; 
$url= "https://api.telegram.org/bot" . TOKEN . "/answerInlineQuery?inline_query_id={$inline_query_id}&results=" . json_encode($mResult); 
file_get_contents($url);