function LingotekOAuthRequester::__construct in Lingotek Translation 7.4
Same name and namespace in other branches
- 7.7 lib/oauth-php/library/LingotekOAuthRequester.php \LingotekOAuthRequester::__construct()
- 7.5 lib/oauth-php/library/LingotekOAuthRequester.php \LingotekOAuthRequester::__construct()
- 7.6 lib/oauth-php/library/LingotekOAuthRequester.php \LingotekOAuthRequester::__construct()
* Construct a new request signer. Perform the request with the doRequest() method below. * * A request can have either one file or a body, not both. * * The files array consists of arrays: * - file the filename/path containing the data for the POST/PUT * - data data for the file, omit when you have a file * - mime content-type of the file * - filename filename for content disposition header * * When OAuth (and PHP) can support multipart/form-data then we can handle more than one file. * For now max one file, with all the params encoded in the query string. * *
Parameters
string request: * @param string method http method. GET, PUT, POST etc. * @param array params name=>value array with request parameters * @param string body optional body to send * @param array files optional files to send (max 1 till OAuth support multipart/form-data posts)
Overrides LingotekOAuthRequestSigner::__construct
File
- lib/
oauth-php/ library/ LingotekOAuthRequester.php, line 61
Class
Code
function __construct($request, $method = null, $params = null, $body = null, $files = null) {
parent::__construct($request, $method, $params, $body);
// When there are files, then we can construct a POST with a single file
if (!empty($files)) {
$empty = true;
foreach ($files as $f) {
$empty = $empty && empty($f['file']) && !isset($f['data']);
}
if (!$empty) {
if (!is_null($body)) {
throw new OAuthException2('When sending files, you can\'t send a body as well.');
}
$this->files = $files;
}
}
}