Skip to content

Commit cb7a115

Browse files
author
Chris Park
committed
Merge branch 'develop'
Conflicts: README.md
2 parents c84ba63 + ec3570d commit cb7a115

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
PHP client binding for Rosette API
44
==================================
5+
See the wiki for more information.
56

67
See the [wiki](https://github.com/rosette-api/php/wiki) for more information.
78

89
Installation
910
------------
1011

11-
`composer require "rosette/api: ~1.0.0"`
12+
`composer require "rosette/api: ~1.0.1"`
1213

1314
Basic Usage
1415
-----------

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rosette/api",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Rosette API PHP client SDK",
55
"license": "Apache",
66
"keywords": [

examples/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Each example, when run, prints its output to the console.
2020

2121
| File Name | What it does |
2222
| ------------- |------------- |
23-
| base64_input.php | Entities using base64 encoded string |
2423
| categories.php | Gets the category of a document at a URL |
2524
| entities.php | Gets the entities from a piece of text |
2625
| entities_linked.php | Gets the linked (to Wikipedia) entities from a piece of text |

source/rosette/api/Api.php

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ private function callEndpoint($parameters, $subUrl)
277277
{
278278
$this->checkVersion($this->service_url);
279279
$this->subUrl = $subUrl;
280-
$this->useMultiPart = $parameters->useMultiPart;
280+
$this->useMultiPart = isset($parameters->useMultiPart) ? $parameters->useMultiPart : null;
281281

282282
if ($this->useMultiPart) {
283283
$content = $parameters->content;
@@ -345,7 +345,7 @@ public function checkVersion($url, $versionToCheck = null)
345345
$resultObject = array_pop((array_slice($resultObject, -1)));
346346
$resultObject = (array) json_decode($resultObject);
347347

348-
if ($resultObject['versionChecked'] === true) {
348+
if (key_exists('versionChecked', $resultObject) && $resultObject['versionChecked'] === true) {
349349
$this->version_checked = true;
350350
} else {
351351
throw new RosetteException(
@@ -385,11 +385,11 @@ private function makeRequest($url, $headers, $data, $method)
385385
if ($this->useMultiPart === null) {
386386
$data = (array) $data;
387387

388-
if ($data['content'] === "") {
388+
if (key_exists('content', $data) && $data['content'] === "") {
389389
unset($data['content']);
390390
}
391391

392-
if ($data['contentUri'] === "") {
392+
if (key_exists('contentUri', $data) && $data['contentUri'] === "") {
393393
unset($data['contentUri']);
394394
}
395395

@@ -430,10 +430,12 @@ private function makeRequest($url, $headers, $data, $method)
430430
$response = explode(PHP_EOL, $response);
431431
$this->setResponseCode($resCode);
432432

433-
if (strlen($response[9]) > 3 && mb_strpos($response[9], "\x1f" . "\x8b" . "\x08", 0) === 0) {
434-
// a gzipped string starts with ID1(\x1f) ID2(\x8b) CM(\x08)
435-
// http://www.gzip.org/zlib/rfc-gzip.html#member-format
436-
$response = gzinflate(substr($response, 10, -8));
433+
if (count($response) > 8) {
434+
if (strlen($response[9]) > 3 && mb_strpos($response[9], "\x1f" . "\x8b" . "\x08", 0) === 0) {
435+
// a gzipped string starts with ID1(\x1f) ID2(\x8b) CM(\x08)
436+
// http://www.gzip.org/zlib/rfc-gzip.html#member-format
437+
$response = gzinflate(substr($response, 10, -8));
438+
}
437439
}
438440
if ($this->getResponseCode() < 500) {
439441
return $response;
@@ -518,7 +520,7 @@ function ($k, $v) {
518520
private function getHttp($url, $headers)
519521
{
520522
$method = 'GET';
521-
$response = $this->makeRequest($url, $headers, $data, $method);
523+
$response = $this->makeRequest($url, $headers, null, $method);
522524

523525
return $response;
524526
}

0 commit comments

Comments
 (0)