ExpinBot/.svn/pristine/cc/ccb76660bb8cdc1d968e666e2a7...

26 lines
723 B
Plaintext

<?php
namespace App\Services;
class TgApi{
public static function GetChatInfo($msg){
$ApiUrl= "https://api.telegram.org/bot{$msg['token']}/getChat?chat_id={$msg['message_chat_id']}";
$ch = curl_init(); // 初始化 cURL
curl_setopt($ch, CURLOPT_URL, $ApiUrl); // 設定請求網址
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // 回傳而不是直接輸出
$response = curl_exec($ch); // 執行請求
$err = curl_error($ch); // 捕捉錯誤
curl_close($ch); // 關閉 cURL
if ($err) {
return ['ok' => false, 'error' => $err];
}
$result = json_decode($response, true);
return $result;
}
}