Skip to content

Commit

Permalink
Merge pull request #114 from J7mbo/glenscott-master
Browse files Browse the repository at this point in the history
Merge glenscott-master
  • Loading branch information
J7mbo committed May 8, 2015
2 parents e576556 + 625e276 commit f41f025
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
20 changes: 14 additions & 6 deletions TwitterAPIExchange.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,19 @@ public function setGetfield($string)
throw new Exception('You can only choose get OR post fields.');
}

$search = array('#', ',', '+', ':');
$replace = array('%23', '%2C', '%2B', '%3A');
$string = str_replace($search, $replace, $string);

$this->getfield = $string;
$getfields = preg_replace('/^\?/', '', explode('&', $string));
$params = array();

foreach ($getfields as $field)
{
if ($field !== '')
{
list($key, $value) = explode('=', $field);
$params[$key] = $value;
}
}

$this->getfield = '?' . http_build_query($params);

return $this;
}
Expand Down Expand Up @@ -210,7 +218,7 @@ public function buildOauth($url, $requestMethod)
/** In case a null is passed through **/
if (isset($split[1]))
{
$oauth[$split[0]] = $split[1];
$oauth[$split[0]] = urldecode($split[1]);
}
}
}
Expand Down
17 changes: 17 additions & 0 deletions test/TwitterAPIExchangeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,21 @@ public function testStatusesDestroy()
/** We've done this now, yay **/
self::$tweetId = null;
}

/**
* GET search/tweets
*
* @see https://dev.twitter.com/rest/reference/get/search/tweets
*/
public function testCanSearchWithHashTag()
{
$url = 'https://api.twitter.com/1.1/search/tweets.json';
$method = 'GET';
$params = '?q=#twitter';

$data = $this->exchange->request($url, $method, $params);
$data = (array)@json_decode($data, true);

$this->assertNotCount(1, $data);
}
}

0 comments on commit f41f025

Please sign in to comment.