Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wxh_internal_api
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
杨培培
wxh_internal_api
Commits
907869c5
Commit
907869c5
authored
Jun 29, 2017
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
php curl 优化
parent
d1f52d7b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
4 deletions
+15
-4
Client.php
src/base/Client.php
+15
-4
No files found.
src/base/Client.php
View file @
907869c5
...
...
@@ -111,8 +111,10 @@ class Client
if
(
$httpCode
==
403
&&
substr
(
$response
,
0
,
6
)
===
'error:'
)
{
$message
=
substr
(
$response
,
6
);
throw
new
ClientException
(
"接口
$api
调用失败: "
.
$message
);
}
elseif
(
$httpCode
===
0
)
{
throw
new
ClientException
(
'接口请求异常: '
.
$response
,
$httpCode
);
}
elseif
(
$httpCode
!=
200
||
$response
===
false
)
{
throw
new
ClientException
(
'接口
请求异常'
,
$httpCode
);
throw
new
ClientException
(
'接口
响应异常: '
.
$response
,
$httpCode
);
}
$data
=
@
json_decode
(
$response
,
true
);
...
...
@@ -196,6 +198,12 @@ class Client
$response
=
curl_exec
(
$ci
);
$httpCode
=
curl_getinfo
(
$ci
,
CURLINFO_HTTP_CODE
);
if
(
$response
===
false
)
{
$errno
=
curl_errno
(
$ci
);
$errmsg
=
curl_error
(
$ci
);
$response
=
"[
$errno
]
$errmsg
"
;
}
//获取调试信息
if
(
$this
->
debug
)
{
$httpInfo
=
curl_getinfo
(
$ci
);
...
...
@@ -204,8 +212,7 @@ class Client
curl_close
(
$ci
);
if
(
$this
->
debug
)
{
echo
'<pre>'
;
echo
"=====INFO=====
\r\n
"
;
echo
"<pre>
\r\n
=====INFO=====
\r\n
"
;
echo
"Remote Address:
{
$httpInfo
[
'primary_ip'
]
}
:
{
$httpInfo
[
'primary_port'
]
}
\r\n
"
,
"Local Address:
{
$httpInfo
[
'local_ip'
]
}
:
{
$httpInfo
[
'local_port'
]
}
\r\n
"
,
"Namelookup Time:
{
$httpInfo
[
'namelookup_time'
]
}
\r\n
"
,
...
...
@@ -215,6 +222,10 @@ class Client
"File Time:
{
$httpInfo
[
'filetime'
]
}
\r\n
"
,
"Total Time:
{
$httpInfo
[
'total_time'
]
}
\r\n
"
;
if
(
isset
(
$errno
))
{
echo
"
\r\n
=====ERROR=====
\r\n
ErrorNo:
$errno
\r\n
ErrorMsg:
$errmsg
\r\n
"
;
}
echo
"
\r\n
=====REQUEST=====
\r\n
"
,
$httpInfo
[
'request_header'
];
if
(
isset
(
$body
))
{
...
...
@@ -222,7 +233,7 @@ class Client
}
echo
"
\r\n
=====RESPONSE=====
\r\n
"
,
$responseHeaders
,
$response
;
echo
'</pre>'
;
echo
"
\r\n
</pre>"
;
}
return
[
$httpCode
,
$response
];
...
...
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