11<?php
22namespace Jleagle \SickBeard ;
33
4- use GuzzleHttp \ Client as Guzzle ;
4+ use Jleagle \ CurlWrapper \ Curl ;
55use Jleagle \SickBeard \Enums \FutureSortEnum ;
66use Jleagle \SickBeard \Enums \LanguageEnum ;
77use Jleagle \SickBeard \Enums \LogEnum ;
88use Jleagle \SickBeard \Enums \ShowsSortEnum ;
99use Jleagle \SickBeard \Enums \SortOrderEnum ;
1010use Jleagle \SickBeard \Exceptions \SickBeardException ;
11+ use Packaged \Helpers \Strings ;
1112
1213class SickBeard
1314{
@@ -749,23 +750,20 @@ protected function _request($params)
749750 $ params ['callback ' ] = $ this ->_callback ;
750751 }
751752
752- $ url = $ this ->_url . '/api/ ' . $ this ->_apiKey . '/? ' ;
753- $ query = http_build_query ($ params );
753+ $ url = $ this ->_url . '/api/ ' . $ this ->_apiKey ;
754754
755- $ client = new Guzzle ();
756- $ response = $ client ->get ($ url . $ query );
755+ $ response = Curl::get ($ url , $ params )->run ();
757756
758- if ($ response ->getStatusCode () != 200 )
757+ if ($ response ->getHttpCode () != 200 )
759758 {
760759 throw new SickBeardException ('Invalid response ' );
761760 }
762761
763- $ body = $ response ->getBody ();
764- $ contentType = $ response ->getHeader ('content-type ' );
762+ $ contentType = $ response ->getContentType ();
765763
766- if (strpos ($ contentType[ 0 ] , 'json ' ) !== false )
764+ if (Strings:: contains ($ contentType , 'json ' , false ) )
767765 {
768- $ array = json_decode ( $ body , true );
766+ $ array = $ response -> getJson ( );
769767
770768 if (isset ($ array ['result ' ]) && $ array ['result ' ] != 'success ' )
771769 {
@@ -776,8 +774,8 @@ protected function _request($params)
776774 }
777775 else
778776 {
779- header ('Content-Type: ' . $ contentType[ 0 ] );
780- return $ body ;
777+ header ('Content-Type: ' . $ contentType );
778+ return $ response -> getOutput () ;
781779 }
782780 }
783781
0 commit comments