8000 Fix #63 Return rate-limiting info only if contained in response · carlpoole/codebird-php@e1a9ff4 · GitHub
[go: up one dir, main page]

Skip to content

Commit e1a9ff4

Browse files
committed
Fix jublo#63 Return rate-limiting info only if contained in response
1 parent 0a2f672 commit e1a9ff4

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ codebird-php - changelog
1515
+ Reset bearer token when requesting a new token
1616
+ #61 Return rate limit details with each API call
1717
+ #60 Support uploading multiple media
18+
- #63 Return rate-limiting info only if contained in response
1819

1920
2.4.1 (2013-06-23)
2021
+ #26 Stringify null and boolean parameters

src/codebird.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,17 +1098,24 @@ protected function _callApi($httpmethod, $method, $method_template, $params = ar
10981098
$httpstatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
10991099
$reply = $this->_parseApiReply($method_template, $result);
11001100
$headers = $this->_parseApiReply($method_template, $result, true);
1101-
$rate = array(
1102-
'limit' => $headers['x-rate-limit-limit'],
1103-
'remaining' => $headers['x-rate-limit-remaining'],
1104-
'reset' => $headers['x-rate-limit-reset']
1105-
);
1101+
$rate = null;
1102+
if (isset($headers['x-rate-limit-limit'])) {
1103+
$rate = array(
1104+
'limit' => $headers['x-rate-limit-limit'],
1105+
'remaining' => $headers['x-rate-limit-remaining'],
1106+
'reset' => $headers['x-rate-limit-reset']
1107+
);
1108+
}
11061109
if ($this->_return_format === CODEBIRD_RETURNFORMAT_OBJECT) {
11071110
$reply->httpstatus = $httpstatus;
1108-
$reply->rate = $rate;
1111+
if ($rate !== null) {
1112+
$reply->rate = $rate;
1113+
}
11091114
} elseif ($this->_return_format === CODEBIRD_RETURNFORMAT_ARRAY) {
11101115
$reply['httpstatus'] = $httpstatus;
1111-
$reply['rate'] = $rate;
1116+
if ($rate !== null) {
1117+
$reply['rate'] = $rate;
1118+
}
11121119
}
11131120
return $reply;
11141121
}

0 commit comments

Comments
 (0)
0