Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions ActiveCollab/Connectors/Curl.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,14 @@ function post($url, $post_data = null, $files = null) {

$counter = 1;

foreach($files as $file) {
$post_data['attachment_' . $counter++] = '@' . $file . ';type=application/octet-stream';
} // foreach
// Support for "File" API endpoint. This endpoint is expecting a single attachment on the request...
if( count( $files ) == 1 ){
$post_data['attachment'] = '@' . $files['attachment_1'] . ';type=application/octet-stream';
} else {
foreach($files as $file) {
$post_data['attachment_' . $counter++] = '@' . $file . ';type=application/octet-stream';
} // foreach
} // if
} // if

curl_setopt($http, CURLOPT_POST, 1);
Expand Down Expand Up @@ -103,6 +108,8 @@ private function execute(&$http) {
case 503:
if(is_string($result) && substr($result, 0, 1) === '{') {
throw new AppException($status, $result); // Known application exception
} else {
throw new AppException($status); // API not always returns JSON body
} // if
} // switch

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
}
],
"require": {

"php": ">=5.3.0"
},
"autoload": {
"psr-0": {
Expand Down