@@ -85,6 +85,7 @@ class Telegram
85
85
*/
86
86
const MY_CHAT_MEMBER = 'my_chat_member ' ;
87
87
88
+ private $ api ;
88
89
private $ bot_token ;
89
90
private $ data ;
90
91
private $ updates = [];
@@ -99,12 +100,13 @@ class Telegram
99
100
* @param $proxy array with the proxy configuration (url, port, type, auth)
100
101
* @return void an instance of the class.
101
102
*/
102
- public function __construct ($ bot_token , $ log_errors = true , array $ proxy = [])
103
+ public function __construct ($ bot_token , $ log_errors = true , array $ proxy = [], $ api = ' https://api.telegram.org ' )
103
104
{
104
105
$ this ->bot_token = $ bot_token ;
105
106
$ this ->data = $ this ->getData ();
106
107
$ this ->log_errors = $ log_errors ;
107
108
$ this ->proxy = $ proxy ;
109
+ $ this ->api = $ api ;
108
110
}
109
111
110
112
/**
@@ -116,7 +118,7 @@ public function __construct($bot_token, $log_errors = true, array $proxy = [])
116
118
*/
117
119
public function endpoint ($ api , array $ content , $ post = true )
118
120
{
119
- $ url = ' https:// api.telegram.org /bot ' .$ this ->bot_token .'/ ' .$ api ;
121
+ $ url = $ this -> api .' /bot ' .$ this ->bot_token .'/ ' .$ api ;
120
122
if ($ post ) {
121
123
$ reply = $ this ->sendAPIRequest ($ url , $ content );
122
124
} else {
@@ -658,7 +660,7 @@ public function stopPoll(array $content)
658
660
*/
659
661
public function downloadFile ($ telegram_file_path , $ local_file_path )
660
662
{
661
- $ file_url = ' https:// api.telegram.org /file/bot ' .$ this ->bot_token .'/ ' .$ telegram_file_path ;
663
+ $ file_url = $ this -> api .' /file/bot ' .$ this ->bot_token .'/ ' .$ telegram_file_path ;
662
664
$ in = fopen ($ file_url , 'rb ' );
663
665
$ out = fopen ($ local_file_path , 'wb ' );
664
666
0 commit comments