Skip to content

Commit

Permalink
Merge pull request #90 from liayn/#89
Browse files Browse the repository at this point in the history
[BUGFIX] Handle request options correctly for current guzzle version
  • Loading branch information
compeak committed Mar 31, 2016
2 parents c8ab32b + 2e791fc commit 44998b9
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 35 deletions.
7 changes: 4 additions & 3 deletions src/Backend/AddThis.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public function getName()
*/
public function getRequest($url)
{
$url = 'http://api-public.addthis.com/url/shares.json?url='.urlencode($url);

return $this->createRequest($url);
return new \GuzzleHttp\Psr7\Request(
'GET',
'http://api-public.addthis.com/url/shares.json?url='.urlencode($url)
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/Facebook.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function getRequest($url)
.urlencode('SELECT total_count FROM link_stat WHERE url="'.$url.'"');
}

return $this->createRequest($query);
return new \GuzzleHttp\Psr7\Request('GET', $query);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/Backend/Flattr.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public function getName()
*/
public function getRequest($url)
{
$url = 'https://api.flattr.com/rest/v2/things/lookup/?url='.urlencode($url);

return $this->createRequest($url);
return new \GuzzleHttp\Psr7\Request(
'GET',
'https://api.flattr.com/rest/v2/things/lookup/?url='.urlencode($url)
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/GooglePlus.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getRequest($url)

$body = Psr7\stream_for(json_encode($json));

return $this->createRequest($gPlusUrl, 'POST', ['body' => $body]);
return new \GuzzleHttp\Psr7\Request('POST', $gPlusUrl, [], $body);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/Backend/LinkedIn.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public function getName()
*/
public function getRequest($url)
{
$url = 'https://www.linkedin.com/countserv/count/share?url='.urlencode($url).'&lang=de_DE&format=json';

return $this->createRequest($url);
return new \GuzzleHttp\Psr7\Request(
'GET',
'https://www.linkedin.com/countserv/count/share?url='.urlencode($url).'&lang=de_DE&format=json'
);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/Backend/Pinterest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public function getName()
*/
public function getRequest($url)
{
$url = 'http://api.pinterest.com/v1/urls/count.json?callback=x&url='.urlencode($url);

return $this->createRequest($url);
return new \GuzzleHttp\Psr7\Request(
'GET',
'http://api.pinterest.com/v1/urls/count.json?callback=x&url='.urlencode($url)
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Backend/Reddit.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function getName()
*/
public function getRequest($url)
{
return $this->createRequest('https://www.reddit.com/api/info.json?url='.urlencode($url));
return new \GuzzleHttp\Psr7\Request('GET', 'https://www.reddit.com/api/info.json?url='.urlencode($url));
}

/**
Expand Down
16 changes: 0 additions & 16 deletions src/Backend/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace Heise\Shariff\Backend;

use GuzzleHttp\ClientInterface;
use Psr\Http\Message\RequestInterface;

/**
* Class Request.
Expand All @@ -24,21 +23,6 @@ public function __construct(ClientInterface $client)
$this->client = $client;
}

/**
* @param string $url
* @param string $method
* @param array $options
*
* @return RequestInterface
*/
protected function createRequest($url, $method = 'GET', $options = [])
{
// $defaults = array('future' => true, 'debug' => true);
$defaults = ['future' => true, 'timeout' => 5.0];

return new \GuzzleHttp\Psr7\Request($method, $url, array_merge($defaults, $options));
}

/**
* {@inheritdoc}
*/
Expand Down
5 changes: 4 additions & 1 deletion src/Backend/StumbleUpon.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ public function getName()
*/
public function getRequest($url)
{
return $this->createRequest('https://www.stumbleupon.com/services/1.01/badge.getinfo?url='.urlencode($url));
return new \GuzzleHttp\Psr7\Request(
'GET',
'https://www.stumbleupon.com/services/1.01/badge.getinfo?url='.urlencode($url)
);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions src/Backend/Xing.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ public function getName()
*/
public function getRequest($url)
{
$query = 'https://www.xing-share.com/spi/shares/statistics?url='.urlencode($url);

return $this->createRequest($query, 'POST');
return new \GuzzleHttp\Psr7\Request(
'POST',
'https://www.xing-share.com/spi/shares/statistics?url='.urlencode($url)
);
}

/**
Expand Down

0 comments on commit 44998b9

Please sign in to comment.