Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23f346f

Browse files
committed
Fix _detectJsonBody, should accept templates
1 parent ac40586 commit 23f346f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/codebird.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -1931,11 +1931,11 @@ protected function _detectMedia($method) {
19311931
/**
19321932
* Detects if API call should use JSON body
19331933
*
1934-
* @param string $method The API method to call
1934+
* @param string $method_template The API method to call
19351935
*
19361936
* @return bool Whether the method is defined as accepting JSON body
19371937
*/
1938-
protected function _detectJsonBody($method) {
1938+
protected function _detectJsonBody($method_template) {
19391939
$json_bodies = [
19401940
'ads/batch/accounts/:account_id/campaigns',
19411941
'ads/batch/accounts/:account_id/line_items',
@@ -1947,7 +1947,7 @@ protected function _detectJsonBody($method) {
19471947
'media/metadata/create',
19481948
'tweets/search/30day/:env'
19491949
];
1950-
return in_array($method, $json_bodies);
1950+
return in_array($method_template, $json_bodies);
19511951
}
19521952

19531953
/**
@@ -2226,7 +2226,7 @@ protected function _callApiPreparationsPost(
22262226
$multipart_boundary = substr($params, 2, $first_newline - 2);
22272227
$request_headers[] = 'Content-Type: multipart/form-data; boundary='
22282228
. $multipart_boundary;
2229-
} elseif ($this->_detectJsonBody($method)) {
2229+
} elseif ($this->_detectJsonBody($method_template)) {
22302230
$authorization = $this->_sign($httpmethod, $url, []);
22312231
$params = json_encode($params);
22322232
$request_headers[] = 'Content-Type: application/json';

0 commit comments

Comments
 (0)