Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

Commit f41f025

Browse files
committed
Merge pull request #114 from J7mbo/glenscott-master
Merge glenscott-master
2 parents e576556 + 625e276 commit f41f025

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

TwitterAPIExchange.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,19 @@ public function setGetfield($string)
136136
throw new Exception('You can only choose get OR post fields.');
137137
}
138138

139-
$search = array('#', ',', '+', ':');
140-
$replace = array('%23', '%2C', '%2B', '%3A');
141-
$string = str_replace($search, $replace, $string);
142-
143-
$this->getfield = $string;
139+
$getfields = preg_replace('/^\?/', '', explode('&', $string));
140+
$params = array();
141+
142+
foreach ($getfields as $field)
143+
{
144+
if ($field !== '')
145+
{
146+
list($key, $value) = explode('=', $field);
147+
$params[$key] = $value;
148+
}
149+
}
150+
151+
$this->getfield = '?' . http_build_query($params);
144152

145153
return $this;
146154
}
@@ -210,7 +218,7 @@ public function buildOauth($url, $requestMethod)
210218
/** In case a null is passed through **/
211219
if (isset($split[1]))
212220
{
213-
$oauth[$split[0]] = $split[1];
221+
$oauth[$split[0]] = urldecode($split[1]);
214222
}
215223
}
216224
}

test/TwitterAPIExchangeTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,21 @@ public function testStatusesDestroy()
254254
/** We've done this now, yay **/
255255
self::$tweetId = null;
256256
}
257+
258+
/**
259+
* GET search/tweets
260+
*
261+
* @see https://dev.twitter.com/rest/reference/get/search/tweets
262+
*/
263+
public function testCanSearchWithHashTag()
264+
{
265+
$url = 'https://api.twitter.com/1.1/search/tweets.json';
266+
$method = 'GET';
267+
$params = '?q=#twitter';
268+
269+
$data = $this->exchange->request($url, $method, $params);
270+
$data = (array)@json_decode($data, true);
271+
272+
$this->assertNotCount(1, $data);
273+
}
257274
}

0 commit comments

Comments
 (0)