git.cweiske.de
/
shpub.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix JSON HTML content sending, according to new tests
[shpub.git]
/
src
/
shpub
/
Request.php
diff --git
a/src/shpub/Request.php
b/src/shpub/Request.php
index 32e25de04d290d42e6a94b408e728242b3afd87a..3d7221dc4cd972b4e0bb00cee103a534e76f4ed6 100644
(file)
--- a/
src/shpub/Request.php
+++ b/
src/shpub/Request.php
@@
-56,7
+56,7
@@
class Request
$data['url'] = $this->url;
}
if ($this->type !== null) {
$data['url'] = $this->url;
}
if ($this->type !== null) {
- $data['type'] =
'h-' . $this->type
;
+ $data['type'] =
array('h-' . $this->type)
;
}
if (count($this->properties)) {
$data['properties'] = $this->properties;
}
if (count($this->properties)) {
$data['properties'] = $this->properties;
@@
-143,11
+143,21
@@
class Request
}
/**
}
/**
+ * Add file upload
+ *
* @param string $fieldName name of file-upload field
* @param array $fileNames list of local file paths
* @param string $fieldName name of file-upload field
* @param array $fileNames list of local file paths
+ *
+ * @return void
*/
public function addUpload($fieldName, $fileNames)
{
*/
public function addUpload($fieldName, $fileNames)
{
+ if ($this->directUpload && $this->sendAsJson) {
+ throw new \Exception(
+ 'Cannot do direct upload with JSON requests'
+ );
+ }
+
if ($this->host->endpoints->media === null
|| $this->directUpload
) {
if ($this->host->endpoints->media === null
|| $this->directUpload
) {
@@
-174,6
+184,10
@@
class Request
}
/**
}
/**
+ * Execute the file upload
+ *
+ * @param string $fileName File path
+ *
* @return string URL at media endpoint
*/
public function uploadToMediaEndpoint($fileName)
* @return string URL at media endpoint
*/
public function uploadToMediaEndpoint($fileName)
@@
-211,7
+225,7
@@
class Request
{
if ($isHtml) {
$this->addProperty(
{
if ($isHtml) {
$this->addProperty(
- 'content', [
'html' => $text
]
+ 'content', [
['html' => $text]
]
);
} else {
$this->addProperty('content', $text);
);
} else {
$this->addProperty('content', $text);
@@
-224,6
+238,8
@@
class Request
*
* @param string $key Parameter name
* @param string|array $values One or multiple values
*
* @param string $key Parameter name
* @param string|array $values One or multiple values
+ *
+ * @return void
*/
public function addProperty($key, $values)
{
*/
public function addProperty($key, $values)
{