Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
meibuyu-rpc
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
without authentication
meibuyu-rpc
Commits
9f676c60
Commit
9f676c60
authored
Jan 26, 2021
by
王源
🎧
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'rpc/product' into test
parents
c23c62da
8d7e4176
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
30 deletions
+12
-30
ProductServiceInterface.php
src/Service/Interfaces/Product/ProductServiceInterface.php
+7
-0
CurlRequest.php
src/Tools/CurlRequest.php
+5
-30
No files found.
src/Service/Interfaces/Product/ProductServiceInterface.php
View file @
9f676c60
...
...
@@ -148,4 +148,11 @@ interface ProductServiceInterface
*/
public
function
getSizesById
(
$id
)
:
array
;
/**
* 完成产品审批
* @param $data
* @author Zero
*/
public
function
downApprove
(
$data
);
}
src/Tools/CurlRequest.php
View file @
9f676c60
...
...
@@ -9,27 +9,17 @@ class CurlRequest
protected
static
function
init
(
$url
,
$httpHeaders
=
[])
{
// Create Curl resource
$ch
=
curl_init
();
// Set URL
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
//Return the transfer as a string
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
1
);
curl_setopt
(
$ch
,
CURLOPT_HEADER
,
true
);
curl_setopt
(
$ch
,
CURLOPT_USERAGENT
,
'PHPClassic/PHPShopify'
);
$headers
=
[];
foreach
(
$httpHeaders
as
$key
=>
$value
)
{
$headers
[]
=
"
$key
:
$value
"
;
}
//Set HTTP Headers
curl_setopt
(
$ch
,
CURLOPT_HTTPHEADER
,
$headers
);
return
$ch
;
}
public
static
function
get
(
$url
,
$httpHeaders
=
[])
...
...
@@ -63,35 +53,20 @@ class CurlRequest
protected
static
function
processRequest
(
$ch
)
{
# Check for 429 leaky bucket error
while
(
1
)
{
$output
=
curl_exec
(
$ch
);
$response
=
new
CurlResponse
(
$output
);
$httpCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
if
(
$httpCode
!=
429
)
{
break
;
}
$output
=
curl_exec
(
$ch
);
$response
=
new
CurlResponse
(
$output
);
$httpCode
=
curl_getinfo
(
$ch
,
CURLINFO_HTTP_CODE
);
if
(
$httpCode
==
429
)
{
$limitHeader
=
explode
(
'/'
,
$response
->
getHeader
(
'X-Shopify-Shop-Api-Call-Limit'
),
2
);
if
(
isset
(
$limitHeader
[
1
])
&&
$limitHeader
[
0
]
<
$limitHeader
[
1
])
{
throw
new
Exception
(
$response
->
getBody
());
}
usleep
(
500000
);
}
if
(
curl_errno
(
$ch
))
{
throw
new
Exception
(
curl_errno
(
$ch
)
.
' : '
.
curl_error
(
$ch
));
}
// close curl resource to free up system resources
curl_close
(
$ch
);
$httpHeader
=
$response
->
getHeaders
();
return
[
$httpCode
,
$httpHeader
,
$response
->
getBody
()];
return
[
$httpCode
,
$response
->
getHeaders
(),
$response
->
getBody
()];
}
}
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