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
b46f700b
Commit
b46f700b
authored
Jun 29, 2017
by
杨培
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
支持 remoteIp 定义远程 IP 地址省去解析过程
parent
907869c5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
2 deletions
+14
-2
Client.php
src/base/Client.php
+13
-2
client_config_dev.php
src/client_config_dev.php
+1
-0
No files found.
src/base/Client.php
View file @
b46f700b
...
@@ -25,6 +25,7 @@ class Client
...
@@ -25,6 +25,7 @@ class Client
protected
$clientId
;
protected
$clientId
;
protected
$clientSecret
;
protected
$clientSecret
;
protected
$apiUrl
;
protected
$apiUrl
;
protected
$remoteIp
;
protected
static
$instance
=
[];
protected
static
$instance
=
[];
protected
static
$config
=
[];
protected
static
$config
=
[];
...
@@ -145,6 +146,14 @@ class Client
...
@@ -145,6 +146,14 @@ class Client
}
}
protected
function
request
(
$url
,
$post
=
''
,
$headers
=
[])
{
protected
function
request
(
$url
,
$post
=
''
,
$headers
=
[])
{
//如果设置了远程IP,则直接用IP连接,省去解析
if
(
$this
->
remoteIp
)
{
$host
=
parse_url
(
$url
,
PHP_URL_HOST
);
$url
=
substr_replace
(
$url
,
$this
->
remoteIp
,
strpos
(
$url
,
$host
),
strlen
(
$host
));
//$url = preg_replace('/^(https?:\/\/)[\w\-\.]+?(\/.*)/i', '${1}'.$this->remoteIp.'$2', $url, 1);
$headers
[]
=
"Host:
$host
"
;
}
$ci
=
curl_init
(
$url
);
$ci
=
curl_init
(
$url
);
//添加客户端信息以辨服务端识别和调试
//添加客户端信息以辨服务端识别和调试
...
@@ -182,7 +191,8 @@ class Client
...
@@ -182,7 +191,8 @@ class Client
curl_setopt_array
(
$ci
,
[
curl_setopt_array
(
$ci
,
[
CURLOPT_HTTPHEADER
=>
$headers
,
CURLOPT_HTTPHEADER
=>
$headers
,
CURLOPT_HTTP_VERSION
=>
CURL_HTTP_VERSION_1_0
,
CURLOPT_HTTP_VERSION
=>
CURL_HTTP_VERSION_1_0
,
CURLOPT_IPRESOLVE
=>
CURL_IPRESOLVE_V4
CURLOPT_IPRESOLVE
=>
CURL_IPRESOLVE_V4
,
//CURLOPT_DNS_USE_GLOBAL_CACHE => false
]);
]);
//调试
//调试
...
@@ -213,7 +223,8 @@ class Client
...
@@ -213,7 +223,8 @@ class Client
if
(
$this
->
debug
)
{
if
(
$this
->
debug
)
{
echo
"<pre>
\r\n
=====INFO=====
\r\n
"
;
echo
"<pre>
\r\n
=====INFO=====
\r\n
"
;
echo
"Remote Address:
{
$httpInfo
[
'primary_ip'
]
}
:
{
$httpInfo
[
'primary_port'
]
}
\r\n
"
,
echo
"Request URL:
$url
\r\n
"
,
"Remote Address:
{
$httpInfo
[
'primary_ip'
]
}
:
{
$httpInfo
[
'primary_port'
]
}
\r\n
"
,
"Local Address:
{
$httpInfo
[
'local_ip'
]
}
:
{
$httpInfo
[
'local_port'
]
}
\r\n
"
,
"Local Address:
{
$httpInfo
[
'local_ip'
]
}
:
{
$httpInfo
[
'local_port'
]
}
\r\n
"
,
"Namelookup Time:
{
$httpInfo
[
'namelookup_time'
]
}
\r\n
"
,
"Namelookup Time:
{
$httpInfo
[
'namelookup_time'
]
}
\r\n
"
,
"Connect Time:
{
$httpInfo
[
'connect_time'
]
}
\r\n
"
,
"Connect Time:
{
$httpInfo
[
'connect_time'
]
}
\r\n
"
,
...
...
src/client_config_dev.php
View file @
b46f700b
...
@@ -14,6 +14,7 @@ return [
...
@@ -14,6 +14,7 @@ return [
],
],
'xue'
=>
[
'xue'
=>
[
'apiUrl'
=>
'http://ct.yunya.com/api'
,
'apiUrl'
=>
'http://ct.yunya.com/api'
,
'remoteIp'
=>
'127.0.0.1'
,
'clientId'
=>
'common'
,
'clientId'
=>
'common'
,
'clientSecret'
=>
'Z2oKgZYYc8mznesYMf1o'
'clientSecret'
=>
'Z2oKgZYYc8mznesYMf1o'
],
],
...
...
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