Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
TelegramBot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
TelegramBot
Commits
bc6ea0ad
Commit
bc6ea0ad
authored
Jul 19, 2016
by
Armando Lüscher
Committed by
GitHub
Jul 19, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #254 from Livich/develop
Fixes issue with file uploading
parents
f92f78e5
52232601
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
7 deletions
+31
-7
Request.php
src/Request.php
+31
-7
No files found.
src/Request.php
View file @
bc6ea0ad
...
...
@@ -171,15 +171,35 @@ class Request
{
$debug_handle
=
TelegramLog
::
getDebugLogTempStream
();
try
{
//Fix so that the keyboard markup is a string, not an object
if
(
isset
(
$data
[
'reply_markup'
])
&&
!
is_string
(
$data
[
'reply_markup'
]))
{
$data
[
'reply_markup'
]
=
(
string
)
$data
[
'reply_markup'
];
}
$request_params
=
[
'debug'
=>
$debug_handle
];
//Check for resources in data
$contains_resource
=
false
;
foreach
(
$data
as
$item
)
{
if
(
is_resource
(
$item
))
{
$contains_resource
=
true
;
break
;
}
}
//Reformat data array in multipart way
if
(
$contains_resource
)
{
foreach
(
$data
as
$key
=>
$item
)
{
$request_params
[
'multipart'
][]
=
array
(
'name'
=>
$key
,
'contents'
=>
$item
);
}
}
else
{
$request_params
[
'form_params'
]
=
$data
;
}
try
{
$response
=
self
::
$client
->
post
(
'/bot'
.
self
::
$telegram
->
getApiKey
()
.
'/'
.
$action
,
[
'debug'
=>
$debug_handle
,
'form_params'
=>
$data
]
$request_params
);
}
catch
(
RequestException
$e
)
{
throw
new
TelegramException
(
$e
->
getMessage
());
...
...
@@ -239,11 +259,15 @@ class Request
*
* @param string $file
*
* @return
\CURLFil
e
* @return
resourc
e
*/
protected
static
function
encodeFile
(
$file
)
{
return
new
\CURLFile
(
$file
);
$fp
=
fopen
(
$file
,
'r'
);
if
(
$fp
===
false
)
{
throw
new
TelegramException
(
'Cannot open '
.
$file
.
' for reading'
);
}
return
$fp
;
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment