Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F633397
importFromLog.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
importFromLog.php
View Options
<?php
require
__DIR__
.
'/../vendor/autoload.php'
;
$filename
=
'logfile.log'
;
$API_KEY
=
'random'
;
$BOT_NAME
=
'bot_name'
;
define
(
'PHPUNIT_TESTSUITE'
,
'some value'
)
;
$CREDENTIALS
=
array
(
'host'
=>
'localhost'
,
'user'
=>
''
,
'password'
=>
''
,
'database'
=>
''
)
;
$update
=
null
;
try
{
// Create Telegram API object
$telegram
=
new
Longman
\
TelegramBot
\
Telegram
(
$API_KEY
,
$BOT_NAME
)
;
$telegram
->
enableMySQL
(
$CREDENTIALS
)
;
foreach
(
new
SplFileObject
(
$filename
)
as
$current_line
)
{
$json_decoded
=
json_decode
(
$update
,
true
)
;
if
(
!
is_null
(
$json_decoded
)
)
{
echo
$update
.
"\n\n"
;
$update
=
null
;
if
(
empty
(
$json_decoded
)
)
{
echo
"Empty update: \n"
;
echo
$update
.
"\n\n"
;
continue
;
}
$telegram
->
processUpdate
(
new
Longman
\
TelegramBot
\
Entities
\
Update
(
$json_decoded
,
$BOT_NAME
)
)
;
}
$update
.=
$current_line
;
}
}
catch
(
Longman
\
TelegramBot
\
Exception
\
TelegramException
$e
)
{
// log telegram errors
echo
$e
;
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Nov 15, 4:44 PM (1 d, 14 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
113530
Default Alt Text
importFromLog.php (1 KB)
Attached To
Mode
R123 php-telegram-bot
Attached
Detach File
Event Timeline