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
f0f5e52c
Commit
f0f5e52c
authored
Oct 07, 2015
by
MBoretto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
$input_raw Removed
parent
a051f40f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
26 deletions
+12
-26
Request.php
src/Request.php
+12
-26
No files found.
src/Request.php
View file @
f0f5e52c
...
...
@@ -17,8 +17,6 @@ class Request
{
private
static
$telegram
;
private
static
$input
;
private
static
$input_raw
;
private
static
$server_response
;
private
static
$methods
=
array
(
'getMe'
,
...
...
@@ -46,10 +44,10 @@ class Request
}
}
public
static
function
setInputRaw
(
$input
_raw
)
public
static
function
setInputRaw
(
$input
)
{
if
(
is_string
(
$input
_raw
))
{
self
::
$input
_raw
=
$input_raw
;
if
(
is_string
(
$input
))
{
self
::
$input
=
$input
;
}
else
{
throw
new
TelegramException
(
"Log input is not a string"
);
}
...
...
@@ -63,7 +61,7 @@ class Request
self
::
setInputRaw
(
file_get_contents
(
'php://input'
));
}
self
::
log
();
return
self
::
$input
_raw
;
return
self
::
$input
;
}
...
...
@@ -77,7 +75,7 @@ class Request
return
false
;
}
$status
=
file_put_contents
(
$path
,
self
::
$input
_raw
.
"
\n
"
,
FILE_APPEND
);
$status
=
file_put_contents
(
$path
,
self
::
$input
.
"
\n
"
,
FILE_APPEND
);
return
$status
;
}
...
...
@@ -109,12 +107,12 @@ class Request
return
$fake_response
;
}
public
static
function
executeCurl
(
i
$action
,
array
$data
)
public
static
function
executeCurl
(
$action
,
array
$data
)
{
$ch
=
curl_init
();
if
(
$ch
===
false
)
{
throw
new
TelegramException
(
'Curl
F
ailed to initialize'
);
throw
new
TelegramException
(
'Curl
f
ailed to initialize'
);
}
$curlConfig
=
array
(
...
...
@@ -136,6 +134,11 @@ class Request
if
(
$result
===
false
)
{
throw
new
TelegramException
(
curl_error
(
$ch
),
curl_errno
(
$ch
));
}
if
(
empty
(
$result
))
{
throw
new
TelegramException
(
'Empty server response'
);
}
curl_close
(
$ch
);
return
$result
;
}
...
...
@@ -153,15 +156,6 @@ class Request
$result
=
self
::
executeCurl
(
$action
,
$data
);
if
(
empty
(
$result
))
{
$response
[
'ok'
]
=
1
;
$response
[
'error_code'
]
=
1
;
$response
[
'description'
]
=
'Empty server response'
;
$result
=
json_encode
(
$response
);
}
//For the getUpdate method log
//self::setInputRaw($result);
$bot_name
=
self
::
$telegram
->
getBotName
();
return
new
ServerResponse
(
json_decode
(
$result
,
true
),
$bot_name
);
}
...
...
@@ -193,7 +187,6 @@ class Request
//sendVoice
public
static
function
sendLocation
(
array
$data
)
{
if
(
empty
(
$data
))
{
throw
new
TelegramException
(
'Data is empty!'
);
}
...
...
@@ -221,15 +214,8 @@ class Request
if
(
$update
=
self
::
$telegram
->
getCustomUpdate
())
{
self
::
setInputRaw
(
$update
);
}
else
{
$result
=
self
::
executeCurl
(
'getUpdates'
,
$data
);
if
(
empty
(
$result
))
{
$response
[
'ok'
]
=
1
;
$response
[
'error_code'
]
=
1
;
$response
[
'description'
]
=
'Empty server response'
;
$result
=
json_encode
(
$response
);
}
self
::
setInputRaw
(
$result
);
}
...
...
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