Skip to content

Commit

Permalink
Use a faster cURL package
Browse files Browse the repository at this point in the history
  • Loading branch information
Jleagle committed Nov 28, 2015
1 parent 162e3dd commit 6075dc1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
13 changes: 10 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@
}
},
"require": {
"php": ">=5.4",
"guzzlehttp/guzzle": "~6.0"
}
"php": ">=5.4.0",
"jleagle/curl-wrapper": "~0.1",
"packaged/helpers": "~1.1"
},
"repositories": [
{
"type": "vcs",
"url": "[email protected]:jleagle/curl-wrapper.git"
}
]
}
22 changes: 10 additions & 12 deletions src/SickBeard.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
<?php
namespace Jleagle\SickBeard;

use GuzzleHttp\Client as Guzzle;
use Jleagle\CurlWrapper\Curl;
use Jleagle\SickBeard\Enums\FutureSortEnum;
use Jleagle\SickBeard\Enums\LanguageEnum;
use Jleagle\SickBeard\Enums\LogEnum;
use Jleagle\SickBeard\Enums\ShowsSortEnum;
use Jleagle\SickBeard\Enums\SortOrderEnum;
use Jleagle\SickBeard\Exceptions\SickBeardException;
use Packaged\Helpers\Strings;

class SickBeard
{
Expand Down Expand Up @@ -749,23 +750,20 @@ protected function _request($params)
$params['callback'] = $this->_callback;
}

$url = $this->_url . '/api/' . $this->_apiKey . '/?';
$query = http_build_query($params);
$url = $this->_url . '/api/' . $this->_apiKey;

$client = new Guzzle();
$response = $client->get($url . $query);
$response = Curl::get($url, $params)->run();

if($response->getStatusCode() != 200)
if($response->getHttpCode() != 200)
{
throw new SickBeardException('Invalid response');
}

$body = $response->getBody();
$contentType = $response->getHeader('content-type');
$contentType = $response->getContentType();

if(strpos($contentType[0], 'json') !== false)
if(Strings::contains($contentType, 'json', false))
{
$array = json_decode($body, true);
$array = $response->getJson();

if(isset($array['result']) && $array['result'] != 'success')
{
Expand All @@ -776,8 +774,8 @@ protected function _request($params)
}
else
{
header('Content-Type: ' . $contentType[0]);
return $body;
header('Content-Type: ' . $contentType);
return $response->getOutput();
}
}

Expand Down

0 comments on commit 6075dc1

Please sign in to comment.