Error handling when uploading too fast
IvorNL opened this issue ยท 8 comments
It seems they rate limit how often you can upload.
Error has occured in file j0k3r/php-imgur-api-client/lib/Imgur/Middleware/ErrorMiddleware.php on line 74:
"Request to: /3/image failed with: "429,You are uploading too fast. Please wait 16 more minutes.,ImgurException,Array"
What could be an option for you?
Creating a custom exception for the uploading too fast?
Yes, that would be best (i now had to debug the code to find out the exact error)
When response is 429, $responseData['data']['error'] is an array and line 74 produces Notice: Array to string conversion.
It looks like the $responseData['data']['error']
will be the array when response is 429
.
Perhaps we have to create the condition for response 429
and try to convert the array to string before merging strings.
If someone can dump the $responseData
and provide it here when response is 429 I'll implement a fix
@j0k3r , my error response
JSON is as follows:
array(3) {
'data' =>
array(3) {
'error' =>
array(4) {
'code' =>
int(429)
'message' =>
string(56) "You are uploading too fast. Please wait 59 more minutes."
'type' =>
string(14) "ImgurException"
'exception' =>
array(0) {
...
}
}
'request' =>
string(13) "/3/image.json"
'method' =>
string(4) "POST"
}
'success' =>
bool(false)
'status' =>
int(400)
}
Here is the formatted JSON response:
{
"data": {
"error": {
"code": 429,
"message": "You are uploading too fast. Please wait 57 more minutes.",
"type": "ImgurException",
"exception": []
},
"request": "\/3\/image.json",
"method": "POST"
},
"success": false,
"status": 400
}
Should be fixed in next release.
Thanks for reporting @IvorNL and for the data to fix the bug @peter279k.