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

Commit 5c2b97e

Browse files
committed
Important fix - automtaic url encoding for #, comma, + and : chars individually
1 parent 0eeed4c commit 5c2b97e

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

TwitterAPIExchange.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public function setPostfields(array $array)
7474
* Set getfield string, example: '?screen_name=J7mbo'
7575
*
7676
* @param string $string Get key and value pairs as string
77+
*
7778
* @return \TwitterAPIExchange Instance of self for method chaining
7879
*/
7980
public function setGetfield($string)
@@ -83,6 +84,10 @@ public function setGetfield($string)
8384
throw new Exception('You can only choose get OR post fields.');
8485
}
8586

87+
$search = array('#', ',', '+', ':');
88+
$replace = array('%23', '%2C', '%2B', '%3A');
89+
$string = str_replace($search, $replace, $string);
90+
8691
$this->getfield = $string;
8792

8893
return $this;
@@ -141,7 +146,6 @@ public function buildOauth($url, $requestMethod)
141146

142147
if (!is_null($getfield))
143148
{
144-
$getfield = str_replace(',', '%2C', $getfield);
145149
$getfields = str_replace('?', '', explode('&', $getfield));
146150
foreach ($getfields as $g)
147151
{

0 commit comments

Comments
 (0)