What can be used to encode a user agent to make:
Mozilla/5.0%20%28Windows;%20U;%20Windows%20NT%205.1;%20en-US;%20rv:1.9.2.13%29%20Gecko/20101203%20Firefox/3.6.13
Rather than:
$ua = urlencode($_SERVER['HTTP_USER_AGENT']);
Which gives this format:
Mozilla%2F5.0+%28Windows%3B+U%3B+Windows+NT+5.1%3B+en-US%3B+rv%3A1.9.2.13%29+Gecko%2F20101203+Firefox%2F3.6.13
Must a function be written?
Would rawurlencode do what you are after?
Have you got the original USER AGENT you are using?
Actually I’ve come up with this, which seems to at least given a matching string.
$ua2 = "$ua";
$ua2 = str_replace('%2F', '/', $ua2);
$ua2 = str_replace('%3B',';',$ua2);
$ua2 = str_replace('%3A', ':', $ua2);
$ua2 = str_replace('+' , '%20' , $ua2);
But the reason I am doing this, is for a SimplePie feed (believe there is no more support there).
And to my utter amazement, even when the output of a test string exactly matches one that is character entered (which succeeds), the request fails.
Given what I am faced with, which does not make sense, I don’t know if there is anything else I can do with this.
Ok, have you the original string used for the encode?
Looks like:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13
sorry for the double post but the system would not allow an edit, and this may save some time:
I’ve recompared and the start and end brackets were omitted, but the request is still not cooperating. Gone over char per char.
$ua2 = “$ua”;
$ua2 = str_replace(‘%2F’, ‘/’, $ua2);
$ua2 = str_replace(‘%3B’,‘;’,$ua2);
$ua2 = str_replace(‘%3A’, ‘:’, $ua2);
$ua2 = str_replace(‘+’ , ‘%20’ , $ua2);
$ua2 = str_replace(‘(’ , ‘%28’ , $ua2);
$ua2 = str_replace(‘)’ , ‘%29’ , $ua2);